Skip to content

Commit

Permalink
Fix 'AttributeError: '_UnixSelectorEventLoop' object has no attribute…
Browse files Browse the repository at this point in the history
… 'call_soon'

See haata#1 for a discussion. The cause of this bug is still unknown to
me. But it likely has been fixed in Python 3.10. For some crazy reason, you can
just keep retrying the offending call, and the attribute will magically
'reappear'.
  • Loading branch information
LasseBlaauwbroek committed Oct 13, 2023
1 parent 941f018 commit d85303c
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion capnp/lib/capnp.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1806,7 +1806,17 @@ cdef cppclass AsyncIoEventPort(EventPort):
if runnable:
assert this.runHandle is None
us = <void*>this;
this.runHandle = this.asyncioLoop.call_soon(lambda: kjloop_runnable_callback(us))
while True:
# TODO: This loop is a workaround for the following occasional nondeterministic bug
# that appears on Python 3.8 and 3.9:
# AttributeError: '_UnixSelectorEventLoop' object has no attribute 'call_soon'
# The cause of this is unknown (either a bug in our code, Cython, or Python).
# It appears to no longer exist in Python 3.10. This can be removed once 3.9 is EOL.
try:
this.runHandle = this.asyncioLoop.call_soon(lambda: kjloop_runnable_callback(us))
break
except AttributeError:
pass
else:
assert this.runHandle is not None
this.runHandle.cancel()
Expand Down

0 comments on commit d85303c

Please sign in to comment.