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

Inconsistent state of event loop across platforms during user startup #2834

Closed
rmartin16 opened this issue Sep 12, 2024 · 1 comment · Fixed by #2835
Closed

Inconsistent state of event loop across platforms during user startup #2834

rmartin16 opened this issue Sep 12, 2024 · 1 comment · Fixed by #2835
Labels
bug A crash or error in behavior. macOS The issue relates to Apple macOS support. windows The issue relates to Microsoft Windows support.

Comments

@rmartin16
Copy link
Member

rmartin16 commented Sep 12, 2024

Describe the bug

The status of the event loop at the time user startup runs is not consistent across platforms. On Linux, iOS, Android, Web, and Textual, the event loop is running when the user's startup code runs....but it is not running on macOS and Windows. Therefore, users cannot use operations that require a running event loop such as calling asyncio.create_task().

Steps to reproduce

Call asyncio.create_task() from toga.App.startup().

Expected behavior

Ideally, the status of the event loop would be consistent across platforms. When it's not, users may experience confusing errors on one platform while their code works on another.

That said, I wouldn't consider this critical. But given this, we should be careful not to recommend operations in startup that require a running event loop to users or in docs. Additionally, now that toga.App.on_running() exists, users can simply do these types of things there instead of in startup().

Screenshots

No response

Environment

  • Operating System: all
  • Python version: all
  • Software versions:
    • Briefcase: 0.3.20.dev207
    • Toga: 0.4.7.dev59+gf379c61e7

Logs

No response

Additional context

Feel free to close if these differences aren't that important or if they are simply inherent to the platform.

@rmartin16 rmartin16 added the bug A crash or error in behavior. label Sep 12, 2024
@freakboy3742 freakboy3742 added macOS The issue relates to Apple macOS support. windows The issue relates to Microsoft Windows support. labels Sep 12, 2024
@freakboy3742
Copy link
Member

Some discrepancies between platforms are to be expected, but this is a pretty big one. Being unable to start an task from inside startup() is a substantial enough limitation, especially given the recent deprecation of add_background_task(), so I think it's worth addressing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A crash or error in behavior. macOS The issue relates to Apple macOS support. windows The issue relates to Microsoft Windows support.
Projects
None yet
2 participants