Skip to content

ports/unix: uasyncio.ThreadSafeFlag appears broken #7965

Description

@crzcrz

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

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    extmodRelates to extmod/ directory in sourceport-unixproposed-closeSuggest this issue should be closed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions