3 ms·
I've recently started to become a little disappointed by Python when I tried to add multithreading code to my application. It turns out that Python does not sup
by amelius 8y ago
I've recently started to become a little disappointed by Python when I tried to add multithreading code to my application. It turns out that Python does not support full multithreading because threads are still tightly coupled to eachother through a global lock, which can lead to performance issues, often in unexpected situations. Now, to mitigate this, the Python people have created a multiprocessing module, which effectively lets you run CPU-intensive tasks in a different process, so you get true multiprocessing. But the downside is that all communication with these processes has to happen through a message-queue or shared-memory interface, which is ... tedious and requires a lot of rewriting.
- windexh8er 8y agoWhat version are you developing in? There's now an Async I/O module: https://docs.python.org/3/library/asyncio.html https://docs.python.org/3/library/asyncio.html
- amelius 8y agoYes, that module is useful until you start running CPU-intensive tasks. At that point you will see unexpected latencies.