I am considering using Python to implement a program, which requires extensive multi-threading. Another requirement is that it will run on desktops, so having many processes, will make the application appear to be messy and harder to kill (in Task Manager). Therefore, I am considering using both the Threading and the Multiprocessing modules to reduce the number of processes. As far as I understand the GIL will apply only to a single process. My question is: Is there any reasons not to mix using the two modules?
Asked
Active
Viewed 2,001 times
2 Answers
4
Note: This warning does not apply to windows.
Be careful! There is a nasty bug lurking with locks when combining threading and multiprocessing which is exposed when using the logging module as well. I've been bitten for the last week with child processes occasionally hanging. Now that I've disabled logging, so far so good (though not the best solution!).:
https://twiki.cern.ch/twiki/bin/view/Main/PythonLoggingThreadingMultiprocessingIntermixedStudy

ricopan
- 662
- 6
- 13
-
6721 bug has nothing to do with threading/multiprocessing on Windows – jfs Oct 20 '12 at 01:30
-
Right, missed the windows tag. – ricopan Oct 23 '12 at 04:29
-
You just saved me hours of debugging... Thanks! – jbaiter Jul 05 '13 at 20:33
1
Other than basic principle of KISS.... go for it, there shouldn't be any issues.

David
- 4,786
- 11
- 52
- 80

Ivan Novick
- 745
- 2
- 8
- 12