Allow threading for sync `use_effect` calls

Ouverte
#1,136 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Évaluation

Difficulté
5/5
Temps estimé
Plus d'une semaine
Accessibilité débutants
35/100
Type d'issue
Fonctionnalité
Clarté
Plutôt claire
Activité
À l'abandon
Stack technique
python
Domaine
backend

Piste de recherche

Start by tracing how sync use_effect calls are handled alongside the ASGI websocket consumer and document the current main-thread behavior. Define whether the default should serialize effects through a single worker, how the proposed threading parameter restores legacy behavior, and whether configurable worker counts are in scope; done requires an agreed design and corresponding coverage.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

priority-2-moderate
Current Situation

Users frequently run into unexpected webserver "freezing" when using sync effects due to Python's single-threaded nature. This is seemingly caused by the ASGI websocket consumer being blocked from receiving/sending data during hook operations. 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 (as long as the user didn't start an operation outside of his use_effect call (which they shouldn't have under React-style programming). 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.

Langage dominant
Python
Étoiles
8.1k
Forks
332
Métriques de merge des PR
Aucune PR mergée en 30 j

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de reactive-python/reactpy

Toutes les issues de reactive-python/reactpy

Issues similaires

Plus d'issues Python

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.