Label reflex child processes in `ps` (e.g. `reflex run [compiler]`)
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
- #7655 par @Akarshkushwaha — fermée sans fusion
Évaluation
- Difficulté
- 3/5
- Temps estimé
- Une demi-journée
- Accessibilité débutants
- 72/100
- Type d'issue
- Fonctionnalité
- Clarté
- Clairement spécifiée
- Activité
- Active
- Stack technique
- python
- Domaine
- backend, developer-experience
Piste de recherche
Start with _compile_app_worker in reflex/reflex.py, the Granian(...) constructions in reflex/utils/exec.py, and the dependency in pyproject.toml. Add process titles for the compiler and relevant Granian services, then check uv run python scripts/check_min_deps.py and add the proposed helper tests, news fragment, and deployment documentation sentence. Done when child processes show their roles in process listings and every Granian construction passes an explicit title.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Describe the Enhancement you want
When reflex run starts, it spawns several child processes (the compiler worker, the Granian backend supervisor and its workers). They inherit the parent's command line, so ps auxww shows a wall of identical reflex run --frontend-port=3000 ... lines (or, with the spawn/forkserver start method, an unreadable python -c from multiprocessing.spawn import spawn_main; ... line). It would be much easier to tell them apart if each child set its own process title with a suffix naming its role:
root 5833 /usr/local/bin/python /usr/local/bin/reflex run --frontend-port=3000 --backend-port=8000 --loglevel=error
root 5853 /usr/local/bin/python /usr/local/bin/reflex run [compiler]
root 5916 /usr/local/bin/bun run dev
root 5917 node /home/user/app/.web/node_modules/.bin/react-router dev --host
root 5924 /usr/local/bin/python /usr/local/bin/reflex run [backend]
root 5925 /usr/local/bin/python /usr/local/bin/reflex run [backend] worker-1
- Which feature do you want to improve?
reflex run/reflex run --env prodprocess management. - What is the benefit? Debugging and ops:
ps,top,htopand container process views immediately show which process is the compiler, the backend supervisor, or a worker, and which one is burning CPU or memory.
Where the processes come from
| Child | Spawned from | Mechanism | What ps shows today |
|---|---|---|---|
| Compiler | reflex/reflex.py _compile_app |
ProcessPoolExecutor(max_workers=1); start method is fork, forkserver or spawn depending on platform / REFLEX_BACKEND_START_METHOD |
fork: parent's full command line; spawn/forkserver: python -c from multiprocessing.spawn ... |
| Backend supervisor + workers (dev and prod) | reflex/utils/exec.py run_granian_backend, run_granian_backend_prod, run_frontend_prod |
Granian Server.serve(), workers via multiprocessing |
same as above, by start method |
| Backend, legacy uvicorn/gunicorn path (only when uvicorn is installed) | run_uvicorn_backend, run_uvicorn_backend_prod |
uvicorn reload supervisor (spawn) or python -m gunicorn |
python -c ... / python -m gunicorn ... |
| Frontend dev server | exec.py run_process_and_launch_url via processes.new_process |
subprocess.Popen(["bun", "run", "dev"]); bun then spawns node .../react-router dev --host |
already self-describing |
Proposed implementation
Granian already supports this. granian.server.Server(process_name=...) sets the supervisor's title to process_name and each worker's title to f"{process_name} worker-{n}". It only needs the granian[pname] extra, which is the setproctitle package (prebuilt wheels for every CPython reflex supports, including 3.14). Without the extra, passing process_name raises ConfigurationError, so the dependency has to be unconditional rather than optional.
- In
pyproject.toml, changegranian[reload] >=2.7.4togranian[reload,pname] >=2.7.4. Check thatuv run python scripts/check_min_deps.pystill passes. - Add a small helper in
reflex/utils/processes.py(orexec.py), e.g.set_process_title(label: str), that builds a title such asf"{sys.executable} {Path(sys.argv[0]).name} run [{label}]"and callssetproctitle.setproctitle(...). Keep thesetproctitleimport inside this one helper. Note thatsetproctitlereplaces the whole title rather than appending, and under spawn the child's own argv is the-cbootstrap line, so constructing the title from scratch is the right approach for every start method. - Call the helper at the top of
_compile_app_workerinreflex/reflex.pywith the labelcompiler. This function already runs inside the child. (Verified: with this call, fork, forkserver and spawn all show.../python3 reflex run [compiler].) - Pass
process_name=to the threeGranian(...)constructions inreflex/utils/exec.py: the dev backend (ParentBoundGranianinrun_granian_backend),run_granian_backend_prod, and the prod static frontend server (run_frontend_prod, which callsrun_granian_backend_prodwith its ownapp_target). Use labels likebackendandfrontend; Granian then names workersreflex run [backend] worker-1. - Add a news fragment (
news/+process-titles.feature.md), a unit test for the helper and for_compile_app_worker(monkeypatchsetproctitle), and a sentence in the deployment docs mentioning thatpsshows labeled processes.
Important: once setproctitle is importable, Granian's default title also changes, to granian asgi 0.0.0.0:8000 app:module for the supervisor and ... worker-1 for workers. So every Granian(...) call in reflex must pass process_name, otherwise the output changes in an unintended way.
Out of scope / caveats
- bun / node frontend processes cannot be labeled from outside.
exec -a "bun [frontend]" bun run devdoes change argv[0] of the bun process on POSIX, but it needs a shell wrapper, does nothing for thenode react-router devgrandchild (which is the one that actually uses CPU), and has no Windows equivalent.bun run devis already recognisable, so leave it alone. Appending a literal[frontend]argument is not safe either, sincebun run devforwards extra arguments to the script. - The legacy uvicorn dev reload worker's only reflex-controlled entry point is the app factory, so labeling it would be hacky. Skip it. gunicorn in prod labels its own master and workers once
setproctitleis installed. prctl(PR_SET_NAME)only changes the 15-charactercommfield, not theargscolumn, so it is not a substitute.- macOS:
setproctitleworks andpsshows the title; Activity Monitor keeps the original name. - Windows:
setproctitleonly sets the console window title; the command line in Task Manager is unchanged. Harmless, no gating needed, but no visible benefit. - On Linux the title is written over the original argv + environ block and is truncated beyond it.
reflex run [compiler]is shorter than any realistic original command line, so this is not a practical concern.
Estimated effort: about half a day including tests.
- Langage dominant
- Python
- Étoiles
- 29k
- Forks
- 1.8k
- Merge moyen
- 3 j 5 h
- PR mergées (30 j)
- 182
Préparer son environnement
Lance le conteneur de développement du projet dans votre navigateur, avec votre propre compte GitHub.
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de reflex-dev/reflex
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 78/100
reflex-dev/reflex#8026 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Kept env.py failure: the "move it aside" hint is dropped and a full traceback is logged when alembic.ini uses a relative script_locationPeut-être pris @MaiAditya l’a pris il y a 13 jours. Ouvertebug release-train
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
reflex-dev/reflex#7856 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
0.9.12 changelog follow-ups: the #7132 "_get_was_touched" entry describes unreachable behaviour, #7115's hasattr/getattr change is undocumented, #7131's wordingPeut-être à nouveau libre Une pull request pour cette issue a été fermée sans être fusionnée. Ouverterelease-train
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
reflex-dev/reflex#7260 · 2 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
ClientStateVar: a component that mounts while the value is non-default never re-renders on the push back to the defaultPeut-être à nouveau libre Une pull request pour cette issue a été fermée sans être fusionnée. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
reflex-dev/reflex#6823 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
documentation upstream
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
reflex-dev/reflex#6436 · 3 commentaires ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de reflex-dev/reflex
Issues similaires
-
todo
Difficulté 1/5 Moins d'une heure Accessibilité débutants 72/100
tonybaloney/CSnakes#864 ·
-
infra
Difficulté 1/5 Moins d'une heure Accessibilité débutants 90/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 65/100
libre-embedded/svgen#72 · 1 commentaire ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Genesis-Embodied-AI/genesis-world#3950 ·
Les mainteneurs répondent en général sous 1 jour
-
accessibility
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Les mainteneurs répondent en général sous 1 jour