Status of Python threading support (GIL removal)?

Martin von Loewis martin.vonloewis at hpi.uni-potsdam.de
Fri Jun 19 10:16:31 EDT 2009


> Digging through my problem, I discovered Python isn't exactly thread
> safe and to solve the issue, there's this Global Interpreter Lock
> (GIL) in place.

It's the opposite: Python is exactly thread safe precisely because it
has the GIL in place.

> Is there any other way to work around the issue aside from forking new
> processes or using something else?

If you know that your (C) code is thread safe on its own, you can 
release the GIL around long-running algorithms, thus using as many
CPUs as you have available, in a single process.

Regards,
Martin



More information about the Python-list mailing list