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

[Feature] Add function to check for active run loop #1499

Closed
laurensvalk opened this issue Mar 1, 2024 · 1 comment
Closed

[Feature] Add function to check for active run loop #1499

laurensvalk opened this issue Mar 1, 2024 · 1 comment
Labels
enhancement New feature or request software: pybricks-micropython Issues with Pybricks MicroPython firmware (or EV3 runtime) topic: multitasking Issues releated to parallel threads, tasks, coroutines, etc.

Comments

@laurensvalk
Copy link
Member

Is your feature request related to a problem? Please describe.
Most of the async-compatible methods we have implemented in C change their behavior depending on whether the run loop is active.

It would be nice to expose this flag so that imported Python functions in block projects can do this too, so they always work as expected. See for example #1498.

It would be nice to ship this in the upcoming firmware so that the firmware can be stable for while and we just add add-on functionality in user code only.

@laurensvalk laurensvalk added enhancement New feature or request topic: multitasking Issues releated to parallel threads, tasks, coroutines, etc. software: pybricks-micropython Issues with Pybricks MicroPython firmware (or EV3 runtime) labels Mar 1, 2024
laurensvalk added a commit to pybricks/pybricks-micropython that referenced this issue Mar 1, 2024
This lets Python users write libraries that can work properly in either async or synchronous mode.

Fixes pybricks/support#1499
laurensvalk added a commit to pybricks/pybricks-micropython that referenced this issue Mar 1, 2024
This lets Python users write libraries that can work properly in either async or synchronous mode.

Fixes pybricks/support#1499
@laurensvalk
Copy link
Member Author

Proposed solution pushed above.

So now you can do:

image

Or

image

And make your imported function work as expected, conditionally:

image

This will let us do things such as #1498 and make it work either way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request software: pybricks-micropython Issues with Pybricks MicroPython firmware (or EV3 runtime) topic: multitasking Issues releated to parallel threads, tasks, coroutines, etc.
Projects
None yet
Development

No branches or pull requests

1 participant