4 ms·
I can think of a lot of reasons to use multiprocessing. I do it quite often. You can't always architect things to fit inside of a `with` context manager. Someti
by whalesalad 3y ago
I can think of a lot of reasons to use multiprocessing. I do it quite often. You can't always architect things to fit inside of a `with` context manager. Sometimes you need fine grain control over when the process starts, stops, how you handle various signals etc.
- tyingq 3y agoThe with context manager doesn't seem mandatory. It seems mostly like a convenience to call executor.shutdown() implicitly when the block is done.
- whalesalad 3y agoI think there is a time and a place for everything. I use concurrent.futures in certain situations when I need to utilize threads/procs to do work in a very rudimentary and naive way. But in more sophisticated systems you want to control startup/shutdown of a process. TBH, assuming your stack allows it, gevent is my preferred mechanism for concurrency in Python. Followed by asyncio. For places where I really need to get my hands dirty I will lean on manually controlling processes/threads.