Skip to content

Conversation

@almarklein
Copy link
Member

@almarklein almarklein commented Dec 18, 2025

The bug

There is a bug in the asyncadapter's Event object; await event.wait() returns immediately. This event object is only really used in await sleep() when USE_THREADED_TIMER is set, which is default on Windows.

The consequence is that it breaks the scheduling when on Windows and using the asyncadapter (using Qt, Wx, or Raw loop).

I apologize for those affected; this should not have happened. I did run with USE_THREADED_TIMER, but apparently only in combination with asyncio. I should have run tests on Windows, or better yet, run Windows-tests on CI, but I was too eager to move forward, because this async stuff was taking sooo long ...

The solution

  • The fix is relatively simple.
  • I also added a Windows and MacOS run to CI to prevent similar issues in the future.
  • Added a unit test to explicitly unit-test the asyncioadapter basics.
  • To let the MacOS tests pass, some tests that do timings needed a bit of leeway (github's runners might be busy so stuff runs somewhat slower than locally).

Ref pyapp-kit/scenex#42 (comment)

Comment on lines 42 to +49
async def wait(self):
if self._is_set:
return
pass
else:
return self # triggers __await__
await self # triggers __await__

def __await__(self):
return {"wait_method": "event", "event": self}
yield {"wait_method": "event", "event": self}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The actual fix.

@almarklein almarklein marked this pull request as ready for review December 18, 2025 15:35
@almarklein almarklein merged commit f3f6303 into main Dec 18, 2025
19 checks passed
@almarklein almarklein deleted the fix-asyncadapter branch December 18, 2025 15:39
@gselzer
Copy link
Contributor

gselzer commented Dec 18, 2025

because this async stuff was taking sooo long ...

😆

@almarklein
Copy link
Member Author

You know when you think a piece of work is just going to take a few hours, and it turns out to take much longer? I have that a lot, but the recent async work was probably the worst case I experienced ...

@gselzer
Copy link
Contributor

gselzer commented Dec 18, 2025

You know when you think a piece of work is just going to take a few hours, and it turns out to take much longer? I have that a lot, but the recent async work was probably the worst case I experienced ...

I'd bet it'd make for a fun blog post!

I totally understand, it's oh so relatable ❤️

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants