MagicStack / MagicStack/uvloop
echoclient.py fails on recent MacOS and Linux Python releases that default to the spawn start‑method
Nessuno ha ancora preso questa issue.
- Lingua principale
- Cython
- Stelle
- 11.9k
- Fork
- 615
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
Recent Python releases on macOS and Linux use the spawn start‑method by default for new processes.
IIRC spawn starts a brand‑new interpreter and imports the target module it relies on pickling to transport the target function.
As only module‑level objects can be pickled and run_test is defined inside the if __name__ == "__main__" block, the child process tries to unpickle and look up as an attribute of the module __mp_main__. That attribute does not exist, and the unpickler raises:
Process ForkServerProcess-2:
File "/usr/lib/python3.14/multiprocessing/process.py", line 320, in _bootstrap
self.run()
~~~~~~~~^^
File "/usr/lib/python3.14/multiprocessing/process.py", line 108, in run
self._target(*self._args, **self._kwargs)
~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.14/concurrent/futures/process.py", line 242, in _process_worker
call_item = call_queue.get(block=True)
File "/usr/lib/python3.14/multiprocessing/queues.py", line 120, in get
return _ForkingPickler.loads(res)
~~~~~~~~~~~~~~~~~~~~~^^^^^
AttributeError: module '__mp_main__' has no attribute 'run_test'
I am not filing a pull request because there are at least three fixes, and which one is implemented depends on the project team's preferences.
The options I see that fit the file's stated minimal changes from upstream constraint:
- Move
run_testto the module level. - As this is I/O bound, change to the
ThreadPoolExecutor - Force the use of
fork()
import multiprocessing
multiprocessing.set_start_method('fork', force=True)
All three options seem to benchmark close to each other on Linux/MacOS. Personally I lean towards the ThreadPoolExecutor option as that is my personal default for I/O bound concurrent operations.
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia da echoclient.py, in particolare dalla definizione di run_test all'interno del blocco main e dalla configurazione del relativo pool di processi. Esamina i tre approcci proposti rispetto al vincolo del progetto di apportare modifiche minime, quindi esegui il client su una release di Python usando spawn per confermare che il problema sia risolto senza modificarne il comportamento previsto.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- testing
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100