rabbitmq: Add on-close callback atomically in creating the connection.

Adding it afterward is inherently racy, and upstream's API is quite
reasonable for avoiding that -- just like we can pass an on-open
callback up front, we can do the same with the on-close callback.

This is a more thorough version of 4adf2d5c2 from back in 2013-04.
This commit is contained in:
Greg Price 2017-11-29 14:58:18 -08:00 committed by Tim Abbott
parent e88c2a7ee4
commit 3c4e4c14c9
1 changed files with 1 additions and 1 deletions

View File

@ -187,8 +187,8 @@ class TornadoQueueClient(SimpleQueueClient):
self.connection = ExceptionFreeTornadoConnection(
self._get_parameters(),
on_open_callback = self._on_open,
on_close_callback = self._on_connection_closed,
)
self.connection.add_on_close_callback(self._on_connection_closed)
def _reconnect(self) -> None:
self.connection = None