The OS will not like it if you use multiprocessing and accidentally end up creating processes without limit.
Is there any simple solution that prevents this from happening (say, by limiting total number of processes, either in Python or in the OS)?
I use Windows, and it behaves really badly (requires hard reboot) when I make a mistake like that. So I’d love it if there’s some code that I can wrap around / add to my application and prevent this from happening.
What you can do is create a short ‘trip-wire’ type module and import it as well as multiprocessing. The trip-wire module will raise an exception if it detects a multiprocessing infinite loop.
Mine looks like this:
And in the main .py file: