-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
One exception and some nice-to-have changes #121
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,7 +97,10 @@ def connection_made(self, transport): | |
self._stream_writer = _StreamWriter(transport, self, self._stream_reader, self._loop) | ||
|
||
def connection_lost(self, exc): | ||
logger.warning("Connection lost exc=%r", exc) | ||
if exc is None: | ||
logger.debug("Connection lost") | ||
else: | ||
logger.warning("Connection lost", exc_info=exc) | ||
self.connection_closed.set() | ||
self.is_open = False | ||
self._close_channels(exception=exc) | ||
|
@@ -199,6 +202,14 @@ def start_connection(self, host, port, login, password, virtualhost, ssl=False, | |
|
||
# for now, we read server's responses asynchronously | ||
self.worker = ensure_future(self.run(), loop=self._loop) | ||
def done_work(w): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that's interesting ! |
||
try: | ||
w.result() | ||
except asyncio.CancelledError: | ||
pass | ||
except Exception as exc: | ||
logger.exception("Worker died", exc_info=exc) | ||
self.worker.add_done_callback(done_work) | ||
|
||
def stop(self): | ||
self.is_open = False | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,8 @@ class AmqpConnectionTestCase(testcase.RabbitTestCase, unittest.TestCase): | |
|
||
@testing.coroutine | ||
def test_connect(self): | ||
_transport, proto = yield from connect(virtualhost=self.vhost, loop=self.loop) | ||
_transport, proto = yield from connect(virtualhost=self.vhost, loop=self.loop, | ||
host=self.host,port=self.port,login=self.login,password=self.password) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. don't forget the spaces :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bah. Will try to remember next time :-P There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just created a branch with a pylint test ;) any suggestion ? @RemiCardona @smurfix #122 |
||
self.assertTrue(proto.is_open) | ||
self.assertIsNotNone(proto.server_properties) | ||
yield from proto.close() | ||
|
@@ -29,6 +30,8 @@ def test_connect_tuning(self): | |
channel_max=channel_max, | ||
frame_max=frame_max, | ||
heartbeat=heartbeat, | ||
host=self.host, port=self.port, | ||
login=self.login, password=self.password, | ||
) | ||
self.assertTrue(proto.is_open) | ||
self.assertIsNotNone(proto.server_properties) | ||
|
@@ -47,7 +50,8 @@ def test_connect_tuning(self): | |
|
||
@testing.coroutine | ||
def test_socket_nodelay(self): | ||
transport, proto = yield from connect(virtualhost=self.vhost, loop=self.loop) | ||
transport, proto = yield from connect(virtualhost=self.vhost, loop=self.loop, | ||
host=self.host,port=self.port, login=self.login,password=self.password) | ||
sock = transport.get_extra_info('socket') | ||
opt_val = sock.getsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY) | ||
self.assertEqual(opt_val, 1) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what to do if we get None here ? (it misses a space between
,
andNone
)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. Probably cancel all consumers …
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do you not get a consumer tag with a basic.cancel frame? It's always there
EDIT: Actually it's a parameter, not an argument, so
frame.payload_decoder.read_xyz()
should be used to read it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK … can you prepare a patch that actually works?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part is now fixed in commit 893f196.