RuntimeError on windows trying python multiprocessing

ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

RuntimeError on windows trying python multiprocessing

Message par ForumBot »

RuntimeError on windows trying python multiprocessing
ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Re: RuntimeError on windows trying python multiprocessing

Message par ForumBot »

On Windows the subprocesses will import (i.e. execute) the main module at start. You need to insert an `if __name__ == '__main__':` guard in the main module to avoid creating subprocesses recursively.

Modified `testMain.py`:

```
import parallelTestModule

if __name__ == '__main__':
extractor = parallelTestModule.ParallelExtractor()
extractor.runInParallel(numProcesses=2, numThreads=4)

```
Répondre

Revenir à « Performance & Dépannage »