What are some good practices in debugging multiprocessing programs in Python?
True multiprocessing Python programs (as opposed to multi-threaded Python programs which have to deal with the dreaded GIL) are no different from those in any other language. They all have the same basic challenges:
Although there are development methods that try to avoid each of these problems, at the end of the day you really need to think about what you are doing. I recommend heavy stress testing — far beyond anything you think might happen in real life — so that you have a good chance of hitting those Windows of Opportunity and blowing up in development as opposed to in the middle of a major demo or during production.
We used to use microsecond-timestamped log files and then created a color-coded log viewing app so we could try to visualize what was happening between N process running on M processors. We also tried (and mostly succeeded) in creating a system that would drive off the log files to recreate the context of the crash.
But the best tool is good design and really wicked, nasty people who try to blow your app out of the water. (Hi, dbell!)
One thing that I find very helpful, is to use the existing logger in the
Additionally, you can access the current process name using:
Apart from that I don't know of anything else except the standard debugging methods like