Skip to content
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

'AioReactor' object has no attribute 'scheduler' #208

Open
asdf8dfafjk opened this issue Jun 2, 2023 · 3 comments
Open

'AioReactor' object has no attribute 'scheduler' #208

asdf8dfafjk opened this issue Jun 2, 2023 · 3 comments

Comments

@asdf8dfafjk
Copy link

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

irc/irc/bot.py

Line 107 in 4c15d34

self.bot.reactor.scheduler.execute_after(intvl, self.check)
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'


@rht
Copy link

rht commented Jun 11, 2023

@asdf8dfafjk do you want to try by adding https://github.com/jaraco/irc/blob/4c15d340105644c127b4a849774e232070a5bfcd/irc/client.py#LL760C1-L762C35 to

def __init__(self, on_connect=__do_nothing, on_disconnect=__do_nothing, loop=None):
?

@andersk
Copy link

andersk commented Jun 11, 2023

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.

@asdf8dfafjk
Copy link
Author

@rht Should I still test? (I sense user: andersk's comment implies it would be futile)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants