Skip to content

ports/unix: uasyncio.ThreadSafeFlag appears broken #7965

@crzcrz

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy