The minimal program to reproduce the issue:
import uasyncio as asyncio
f = asyncio.ThreadSafeFlag()
async def main():
await f.wait()
asyncio.run(main())
The result:
Traceback (most recent call last):
File "t.py", line 8, in <module>
File "/usr/lib/micropython/uasyncio/core.py", line 222, in run
File "/usr/lib/micropython/uasyncio/core.py", line 191, in run_until_complete
File "/usr/lib/micropython/uasyncio/core.py", line 176, in run_until_complete
File "t.py", line 6, in main
File "/usr/lib/micropython/uasyncio/event.py", line 57, in wait
File "/usr/lib/micropython/uasyncio/core.py", line 94, in queue_read
File "/usr/lib/micropython/uasyncio/core.py", line 79, in _enqueue
TypeError: can't convert NoneType to int
I poked around it a bit, and the flow to the failure is as follows:
|
self.poller.register(s, select.POLLIN if idx == 0 else select.POLLOUT) |
|
int fd = get_fd(args[1]); |
|
mp_uint_t res = stream_p->ioctl(fdlike, MP_STREAM_GET_FILENO, 0, &err); |
This ends up in ThreadSafeFlag.ioctl(), which returns None for any request other than MP_STREAM_POLL and causes the exception above.
|
def ioctl(self, req, flags): |
|
if req == 3: # MP_STREAM_POLL |
|
return self._flag * flags |
|
return None |
The minimal program to reproduce the issue:
The result:
I poked around it a bit, and the flow to the failure is as follows:
micropython/extmod/uasyncio/core.py
Line 79 in cb99ca9
micropython/ports/unix/moduselect.c
Line 88 in cb99ca9
micropython/ports/unix/moduselect.c
Line 76 in cb99ca9
This ends up in
ThreadSafeFlag.ioctl(), which returns None for any request other thanMP_STREAM_POLLand causes the exception above.micropython/extmod/uasyncio/event.py
Lines 47 to 50 in cb99ca9