multiprocessing.Process generates FileNotFoundError when argument isn't explicitly referenced
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 45/100
- Issue-Typ
- Bug
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Veraltet
- Tech-Stack
- python
- Bereich
- operating-systems
Rechercherichtung
Führe das bereitgestellte Skript unter Linux mit der Startmethode spawn aus und lies anschließend multiprocessing/spawn.py und multiprocessing/synchronize.py im Bereich des Tracebacks. Vergleiche das inline angegebene multiprocessing.Value-Argument mit dem explizit referenzierten Wert und dem Verhalten von fork. Erledigt bedeutet, dass der gemeldete FileNotFoundError behoben oder eindeutig dokumentiert ist und eine Regressionstestabdeckung für den Reproduzierer vorhanden ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Bug report
This is a continuation for the possible bug mentioned in issue https://github.com/python/cpython/issues/82236 which was closed because DonnyBrown, the submitter, didn't provide enough information.
DonnyBrown was getting a FileNotFoundError when starting a process with multiprocessing.Process that uses an argument that doesn't have an explicit reference. I'm able to reproduce the same error using the test code DonnyBrown provided in that issue on Ubuntu Desktop LTS 22.04 x86-64 with CPython 3.10.4. @iritkatriel mentioned that they were unable to reproduce the error on Windows 10 with Python 3.10.
I can also reproduce the error using this slightly modified/simpler version of DonnyBrown's test code that I have been testing:
import multiprocessing
def demo(argument):
print(argument)
if __name__=="__main__":
multiprocessing.set_start_method("spawn") # Changing this to "fork" (on platforms where it is
# available) can also cause the below code to work.
process=multiprocessing.Process(target=demo, args=[multiprocessing.Value("i", 0)]) # FAILS
#process=multiprocessing.Process(target=demo, args=[0]) # WORKS
#reference_To_Number=multiprocessing.Value("i", 0) # WORKS
#process=multiprocessing.Process(target=demo, args=[reference_To_Number])
process.start()
process.join()
The traceback I get with the above code is:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python3.10/multiprocessing/spawn.py", line 116, in spawn_main
exitcode = _main(fd, parent_sentinel)
File "/usr/lib/python3.10/multiprocessing/spawn.py", line 126, in _main
self = reduction.pickle.load(from_parent)
File "/usr/lib/python3.10/multiprocessing/synchronize.py", line 110, in __setstate__
self._semlock = _multiprocessing.SemLock._rebuild(*state)
FileNotFoundError: [Errno 2] No such file or directory
The above code can be made to work on my test system by making any of the following changes:
- Change the process start method to "fork" instead.
- Change the process argument to a simple integer instead of a multiprocessing.Value.
- Assign the multiprocessing.Value to a variable and change the process argument to use the variable.
I'm not a Python expert so maybe this is the expected behavior when spawning a process directly with a multiprocessing.Value but it does seem odd that making any of the above mentioned changes causes the code to work or that (based on @iritkatriel's success with DonnyBrown's test code) running it on Windows 10 (which uses the "spawn" start method) will probably cause the code to work.
Your environment
- CPython versions tested on: 3.10.4
- Operating system and architecture: Linux, Ubuntu Desktop LTS 22.04, x86-64
- Vorherrschende Sprache
- Python
- Sterne
- 77.2k
- Forks
- 36k
- Ø Merge
- 1 T. 9 Std.
- Gemergte PRs (30 T.)
- 558
Beitragsleitfaden
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus python/cpython
-
docs pending
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
-
stdlib type-feature
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
-
stdlib type-feature
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
-
build type-bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
-
stdlib topic-email type-feature
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
bancolombia/sentinel#23 ·
-
test md OffenCI
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
langchain-ai/deepagents#6450 ·
-
bug client
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100