Open
Description
I appreciate that this is unlikely to be a priority but I thought it worth recording for future reference. There is scope for a subtle bug to occur in user code where a contributed module is used:
import uasyncio as asyncio
import some_module
bar = some_module.Bar() # Constructor calls get_event_loop()
# and renders these args inoperative
loop = asyncio.get_event_loop(runq_len=40, waitq_len=40)
I can envisage this puzzling users unfamiliar with the code of uasyncio
and/or some_module
. It could be avoided (with a trivial got_event_loop()
function) if the class could test for instantiation.
uasyncio.core.py:
def got_event_loop():
return _event_loop is not None
In some_module
:
class Foo():
def __init__(self):
if asyncio.got_event_loop():
loop = asyncio.get_event_loop()
loop.create_task(self._run())
else:
raise OSError('Foo class requires an event loop instance')
Metadata
Assignees
Labels
No labels
Activity