irc
irc copied to clipboard
'AioReactor' object has no attribute 'scheduler'
Hello, I'm using this package via github.com/zulip/zulip 's irc<->zulip bridge, and am coming across the following error. The zulip integration uses the async reactor but @rht 's research says https://github.com/jaraco/irc/blob/4c15d340105644c127b4a849774e232070a5bfcd/irc/bot.py#L107 incorrectly assumes a sync reactor and that the scheduler attribute referred to in the said code doesn't exist for the async reactor.
Could you suggest a fix here?
Full error message:
Exception in callback _SelectorSocketTransport._call_connection_lost(ReadTimeout(R...meout=15.0)")))
handle: <Handle _SelectorSocketTransport._call_connection_lost(ReadTimeout(R...meout=15.0)")))>
Traceback (most recent call last):
File "/nix/store/r85cm22i6058g4zj76w05rzvqwil6d2g-python3-3.11.1/lib/python3.11/asyncio/events.py", line 80, in _run
self._context.run(self._callback, *self._args)
File "/nix/store/r85cm22i6058g4zj76w05rzvqwil6d2g-python3-3.11.1/lib/python3.11/asyncio/selector_events.py", line 1117, in _call_connection_lost
super()._call_connection_lost(exc)
File "/nix/store/r85cm22i6058g4zj76w05rzvqwil6d2g-python3-3.11.1/lib/python3.11/asyncio/selector_events.py", line 875, in _call_connection_lost
self._protocol.connection_lost(exc)
File "/home/zx/zulip/python-zulip-api/zulip-api-py3-venv/lib/python3.11/site-packages/irc/client_aio.py", line 82, in connection_lost
self.connection.disconnect()
File "/home/zx/zulip/python-zulip-api/zulip-api-py3-venv/lib/python3.11/site-packages/irc/client_aio.py", line 214, in disconnect
self._handle_event(Event("disconnect", self.server, "", [message]))
File "/home/zx/zulip/python-zulip-api/zulip-api-py3-venv/lib/python3.11/site-packages/irc/client.py", line 376, in _handle_event
self.reactor._handle_event(self, event)
File "/home/zx/zulip/python-zulip-api/zulip-api-py3-venv/lib/python3.11/site-packages/irc/client.py", line 922, in _handle_event
result = handler.callback(connection, event)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/zx/zulip/python-zulip-api/zulip-api-py3-venv/lib/python3.11/site-packages/irc/bot.py", line 202, in _on_disconnect
self.recon.run(self)
File "/home/zx/zulip/python-zulip-api/zulip-api-py3-venv/lib/python3.11/site-packages/irc/bot.py", line 107, in run
self.bot.reactor.scheduler.execute_after(intvl, self.check)
^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'AioReactor' object has no attribute 'scheduler'
@asdf8dfafjk do you want to try by adding https://github.com/jaraco/irc/blob/4c15d340105644c127b4a849774e232070a5bfcd/irc/client.py#LL760C1-L762C35 to https://github.com/jaraco/irc/blob/4c15d340105644c127b4a849774e232070a5bfcd/irc/client_aio.py#L257 ?
The IScheduler
interface and the tempora
library the implementation is based on are not designed for an async application. They assume an architecture where the application is repeatedly polling to check whether one of the scheduled jobs should run with .run_pending()
. In an async application, a timer should be scheduled with the event loop (or a higher-level interface like asyncio.sleep
in a task); the event loop automatically dispatches the job at the right time without polling.
@rht Should I still test? (I sense user: andersk's comment implies it would be futile)