mirror of https://github.com/celery/kombu.git
Handle librabbitmq fileno socket not connected raising ValueError (#878)
* Handle librabbitmq fileno socket not connected raises ValueError * Test client objects set to None * Assert that librabbitmq's conn.fileno is called
This commit is contained in:
parent
b975713d81
commit
b0512725f6
|
@ -146,7 +146,7 @@ class Transport(base.Transport):
|
|||
channel.connection = None
|
||||
try:
|
||||
os.close(connection.fileno())
|
||||
except OSError:
|
||||
except (OSError, ValueError):
|
||||
pass
|
||||
connection.channels.clear()
|
||||
connection.callbacks.clear()
|
||||
|
|
|
@ -125,6 +125,18 @@ class test_Transport(lrmqCase):
|
|||
self.T._collect(conn)
|
||||
close.assert_called_with(conn.fileno())
|
||||
|
||||
def test_collect__with_fileno_raising_value_error(self):
|
||||
conn = Mock(name='connection')
|
||||
conn.channels = {1: Mock(name='chan1'), 2: Mock(name='chan2')}
|
||||
with patch('os.close') as close:
|
||||
self.T.client = self.client
|
||||
conn.fileno.side_effect = ValueError("Socket not connected")
|
||||
self.T._collect(conn)
|
||||
close.assert_not_called()
|
||||
conn.fileno.assert_called_with()
|
||||
assert self.client.drain_events is None
|
||||
assert self.T.client is None
|
||||
|
||||
def test_register_with_event_loop(self):
|
||||
conn = Mock(name='conn')
|
||||
loop = Mock(name='loop')
|
||||
|
|
Loading…
Reference in New Issue