© Joey Bernard 2016

Joey Bernard, Python Recipes Handbook, 10.1007/978-1-4842-0241-8_12

12. Concurrency

Joey Bernard

(1)Fredericton, New Brunswick, Canada

Computers have been getting faster and faster over the decades, but we are starting to bump into some of the limitations of physics. This means that in order to get more work done, we need to move to using multiple processes in parallel. There are several techniques available within Python to support concurrent execution of code.

The first technique is to use threads to break up the work. The main problem with this method is that it suffers from the bottleneck caused by the GIL (Global Interpreter Lock ). Threads that are doing I/O or using certain modules, such as numpy, can get around this bottleneck. ...

Get Python Recipes Handbook: A Problem-Solution Approach now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.