Skip to content

Commit

Permalink
tornado: Replace deprecated IOLoop.instance alias.
Browse files Browse the repository at this point in the history
Signed-off-by: Anders Kaseorg <anders@zulip.com>
  • Loading branch information
andersk committed Mar 22, 2022
1 parent f4c6034 commit 99f6ddf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions zerver/lib/queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ def _on_connection_open_error(
"TornadoQueueClient couldn't connect to RabbitMQ, retrying in %d secs...",
retry_secs,
)
ioloop.IOLoop.instance().call_later(retry_secs, self._reconnect)
ioloop.IOLoop.current().call_later(retry_secs, self._reconnect)

def _on_connection_closed(
self, connection: pika.connection.Connection, reason: Exception
Expand All @@ -315,7 +315,7 @@ def _on_connection_closed(
"TornadoQueueClient lost connection to RabbitMQ, reconnecting in %d secs...",
retry_secs,
)
ioloop.IOLoop.instance().call_later(retry_secs, self._reconnect)
ioloop.IOLoop.current().call_later(retry_secs, self._reconnect)

def _on_open(self, connection: pika.connection.Connection) -> None:
assert self.connection is not None
Expand Down
4 changes: 2 additions & 2 deletions zerver/tornado/event_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def timeout_callback() -> None:
heartbeat_event = create_heartbeat_event()
self.add_event(heartbeat_event)

ioloop = tornado.ioloop.IOLoop.instance()
ioloop = tornado.ioloop.IOLoop.current()
interval = HEARTBEAT_MIN_FREQ_SECS + random.randint(0, 10)
if self.client_type_name != "API: heartbeat test":
self._timeout_handle = ioloop.call_later(interval, timeout_callback)
Expand All @@ -265,7 +265,7 @@ def disconnect_handler(self, client_closed: bool = False) -> None:
self.current_handler_id = None
self.current_client_name = None
if self._timeout_handle is not None:
ioloop = tornado.ioloop.IOLoop.instance()
ioloop = tornado.ioloop.IOLoop.current()
ioloop.remove_timeout(self._timeout_handle)
self._timeout_handle = None

Expand Down

0 comments on commit 99f6ddf

Please sign in to comment.