CPython thread starvation

MRAB python at mrabarnett.plus.com
Fri Apr 27 18:58:08 EDT 2012


On 27/04/2012 23:30, Dennis Lee Bieber wrote:
>
> 	Oh, continuation thought...
>
> 	If the workers are calling into C-language operations, unless those
> operations release the GIL, it doesn't matter what the OS or Python
> thread switch timings are. The OS may interrupt the thread (running
> C-language code), pass control to the Python interpreter which finds the
> GIL is locked, and just blocks -- control passes back to the interrupted
> thread.
>
> 	Any long-running C-language function should release the GIL while
> doing things with local data -- and reacquire the GIL when it needs to
> manipulate Python data structures or returning...

The OP mentioned parsing webpages. If that involves the re module at
some point, it doesn't release the GIL while it's looking for matches.



More information about the Python-list mailing list