From cfe6a11e39725f42ac3fffac138d2de1587fe756 Mon Sep 17 00:00:00 2001 From: Jim Mussared Date: Thu, 14 Sep 2023 14:07:04 +1000 Subject: [PATCH 1/2] extmod/asyncio/event.py: Fix ThreadSafeFlag.ioctl return. iobase_ioctl expects that an ioctl method must return an integer, and will raise otherwise. This was tripping up aioble on Unix, where the new hybrid modselect.c implementation will attempt to extract a file descriptor from the pollable via ioctl(MP_STREAM_GET_FILENO). However, ThreadSafeFlag's ioctl only supported MP_STREAM_POLL, and returned None otherwise. This makes it return `-1` (to match tests/extmod/select_poll_custom.py). It should probably be `-22` (corresponding to MP_EINVAL), but the value is never checked, and MP_EINVAL can be a different value on different ports. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared --- extmod/asyncio/event.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extmod/asyncio/event.py b/extmod/asyncio/event.py index e0b41f7324244..f11bb14e58403 100644 --- a/extmod/asyncio/event.py +++ b/extmod/asyncio/event.py @@ -49,7 +49,7 @@ def __init__(self): def ioctl(self, req, flags): if req == 3: # MP_STREAM_POLL return self.state * flags - return None + return -1 # Other requests are unsupported def set(self): self.state = 1 From fae83a6b4d0d7b3e4917fdeb9b7966a06161af54 Mon Sep 17 00:00:00 2001 From: Jim Mussared Date: Thu, 14 Sep 2023 15:26:23 +1000 Subject: [PATCH 2/2] tests/extmod/asyncio_threadsafeflag.py: Update for unix select. 1. Remove the skip for detecting support for polling user-defined objects as this is always possible now on all ports. 2. Don't print when the scheduled task runs as the ordering of this relative to the other prints is dependent on other factors (e.g. if using the native emitter). This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared --- tests/extmod/asyncio_threadsafeflag.py | 13 ------------- tests/extmod/asyncio_threadsafeflag.py.exp | 2 -- 2 files changed, 15 deletions(-) diff --git a/tests/extmod/asyncio_threadsafeflag.py b/tests/extmod/asyncio_threadsafeflag.py index 46da1b7b487a8..e8798afcf5f52 100644 --- a/tests/extmod/asyncio_threadsafeflag.py +++ b/tests/extmod/asyncio_threadsafeflag.py @@ -16,17 +16,6 @@ raise SystemExit -try: - # Unix port can't select/poll on user-defined types. - import select - - poller = select.poll() - poller.register(asyncio.ThreadSafeFlag()) -except TypeError: - print("SKIP") - raise SystemExit - - async def task(id, flag): print("task", id) await flag.wait() @@ -34,9 +23,7 @@ async def task(id, flag): def set_from_schedule(flag): - print("schedule") flag.set() - print("schedule done") async def main(): diff --git a/tests/extmod/asyncio_threadsafeflag.py.exp b/tests/extmod/asyncio_threadsafeflag.py.exp index 757115ac4bdd4..0c62eae9d096e 100644 --- a/tests/extmod/asyncio_threadsafeflag.py.exp +++ b/tests/extmod/asyncio_threadsafeflag.py.exp @@ -9,8 +9,6 @@ yield task 2 set event yield -schedule -schedule done wait task task 2 done ---- 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