Skip to content

Commit

Permalink
Update asyncio ioloop handling (https://neon-ai.sentry.io/issues/6222…
Browse files Browse the repository at this point in the history
  • Loading branch information
NeonDaniel committed Jan 16, 2025
1 parent ec83ddc commit 64dd025
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions neon_mq_connector/consumers/select_consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ def __init__(self,
"""
threading.Thread.__init__(self, *args, **kwargs)
try:
self._io_loop = get_event_loop()
get_event_loop()
except RuntimeError:
self._io_loop = new_event_loop()
set_event_loop(new_event_loop())
self._consumer_started = Event() # annotates that ConsumerThread is running
self._channel_closed = threading.Event()
self._is_consumer_alive = True # annotates that ConsumerThread is alive and shall be recreated
Expand All @@ -105,8 +105,7 @@ def create_connection(self) -> pika.SelectConnection:
return pika.SelectConnection(parameters=self.connection_params,
on_open_callback=self.on_connected,
on_open_error_callback=self.on_connection_fail,
on_close_callback=self.on_close,
custom_ioloop=self._io_loop)
on_close_callback=self.on_close)

def on_connected(self, _):
"""Called when we are fully connected to RabbitMQ"""
Expand Down

0 comments on commit 64dd025

Please sign in to comment.