Skip to content
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

Add Winforms-compatible asyncio Proactor. #741

Merged
merged 7 commits into from
Oct 12, 2019

Conversation

freakboy3742
Copy link
Member

@freakboy3742 freakboy3742 commented Sep 29, 2019

Integrates the Winforms event handling lifecycle with the asyncio event loop.

This is done by instantiating a Proactor, but customizing the Proactor so that run_forever() is split into two parts; setup_run_forever() and tick(). The tick() component is what historically would have been run as a tight "while True" loop; in this version, the call to tick is scheduled to run every 5ms using the winforms event infrastructure.

It also involves some refactoring of the winforms libs - they were starting to get unwieldly, and introducing the Proactor was a good opportunity to modularize that code.

Huge thanks for @hawkowl for the many, many pointers on getting this going.

@freakboy3742
Copy link
Member Author

This is a work in progress; there's one more improvement to come. The current implementation relies on the existence of a main window, and ties the delayed execution to the form for that window. @hawkowl suggested an additional change to use ApplicationContext() as the main runnable, which would enable us to decouple the "application" lifecycle from the main form.

@freakboy3742
Copy link
Member Author

The underlying bug preventing a full transition to an AppContext version of this patch can be found here: pythonnet/pythonnet#965

@freakboy3742 freakboy3742 merged commit a9e27f5 into beeware:master Oct 12, 2019
@freakboy3742 freakboy3742 deleted the async-windows branch October 12, 2019 00:47
@freakboy3742
Copy link
Member Author

I've merged this because it doesn't appear that there's a simple fix for the Python.net binding, and an asyncio implementation that works at all is better than what we have right now.

I've opened #750 to track the future work that can be done to improve this implementation.

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.

2 participants