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

Modify startup on Windows and macOS so event loop is running when startup is called #2835

Merged
merged 3 commits into from
Sep 13, 2024

Conversation

freakboy3742
Copy link
Member

Modifies the startup sequence of Windows and macOS apps so that the event loop is guaranteed to be running at the point startup is invoked. This ensures it is possible to call asyncio.create_task().

This isn't an issue on other platforms:

  • On GTK, startup is triggered by the GTK app's activate message, which requires the app loop is running
  • On iOS, startup is triggered by the receipt of the application:didFinishLaunchingWithOptions: selector on the AppDelegate, which requires the app loop is running
  • On Android, startup is triggered explicitly when the main loop is started; but the main loop is cooperative, based on the Java context handling events.
  • On Web, there's no explicit event loop creation; asyncio works as soon as the interpreter has started.
  • On Textual, the app isn't created until the app itself is mounted.

Fixes #2834.

PR Checklist:

  • All new features have been tested
  • All new features have been documented
  • I have read the CONTRIBUTING.md file
  • I will abide by the code of conduct

Copy link
Member

@rmartin16 rmartin16 left a comment

Choose a reason for hiding this comment

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

My initial concern was this is going to change the order of events at startup...but I think in reality it just slightly delays when the last bit of startup code runs 👍🏼

changes/2834.bugfix.rst Outdated Show resolved Hide resolved
Co-authored-by: Russell Martin <russell@rjm.li>
@freakboy3742 freakboy3742 merged commit fed0c7c into beeware:main Sep 13, 2024
38 checks passed
@freakboy3742 freakboy3742 deleted the async-startup branch September 13, 2024 01:52
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.

Inconsistent state of event loop across platforms during user startup
2 participants