May 2019
Intermediate to advanced
542 pages
13h 37m
English
No discussion of multithreading in Python is complete without addressing the global interpreter lock (GIL). The GIL is part of the memory management system in the official Python implementation (CPython). Essentially, it is like the mutex that we used in our HashRunner class—just as a HashRunner class has to acquire the file_lock mutex before it can write to the output, any thread in a Python application must acquire the GIL before it can execute any Python code. In other words, only one thread can execute Python code at a time.
At first glance, this may appear to make multithreading in Python a futile pursuit; after all, what's the point of creating multiple threads if only one thread can execute Python code ...
Read now
Unlock full access