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

Allow threading for sync use_effect calls #1136

Open
Archmonger opened this issue Aug 28, 2023 · 0 comments
Open

Allow threading for sync use_effect calls #1136

Archmonger opened this issue Aug 28, 2023 · 0 comments
Labels
priority-2-moderate Should be resolved on a reasonable timeline. type-feature About new capabilities

Comments

@Archmonger
Copy link
Contributor

Archmonger commented Aug 28, 2023

Current Situation

Users frequently run into unexpected webserver "freezing" when using sync effects due to Python's single-threaded nature. This behavior doesn't seem to match up with equivalent JavaScript server side frameworks.

Proposed Actions

By default we should run all sync effects in a ThreadPoolExecutor(max_workers=1). This effectively runs all sync effects in a background thread. Additionally, by running all effects in the same worker thread (max_workers=1) this implementation is semi-threadsafe. For operations that must run on the main thread, we need a @use_effect(threading: bool = ...) parameter to switch back to legacy behavior.

We could also consider a reactpy.config.USE_EFFECT_WORKERS=... setting to allow users to modify the value of max_workers.

@Archmonger Archmonger added the type-feature About new capabilities label Aug 28, 2023
@Archmonger Archmonger mentioned this issue Nov 28, 2023
2 tasks
@Archmonger Archmonger added the priority-2-moderate Should be resolved on a reasonable timeline. label Feb 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority-2-moderate Should be resolved on a reasonable timeline. type-feature About new capabilities
Projects
None yet
Development

No branches or pull requests

1 participant