Explain Python extensions multithreading
Posted
by Checkers
on Stack Overflow
See other posts from Stack Overflow
or by Checkers
Published on 2010-05-13T08:34:58Z
Indexed on
2010/05/13
12:14 UTC
Read the original article
Hit count: 474
Python interpreter has a Global Interpreter Lock, and it is my understanding that extensions must acquire it in a multi-threaded environment. But Boost.Python HOWTO page says the extension function must release the GIL and reacquire it on exit.
I want to resist temptation to guess here, so I would like to know what should be GIL locking patterns in the following scenarios:
- Extension is called from python (presumably running in a python thread).
- And extension's background thread calls back into
Py_*
functions.
And a final question is, why the linked document says the GIL should be released and re-acquired?
© Stack Overflow or respective owner