-
Notifications
You must be signed in to change notification settings - Fork 9
Fix asyncadapter.Event #160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| 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} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The actual fix.
😆 |
|
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 ❤️ |
The bug
There is a bug in the asyncadapter's
Eventobject;await event.wait()returns immediately. This event object is only really used inawait sleep()whenUSE_THREADED_TIMERis 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
Ref pyapp-kit/scenex#42 (comment)