releasing interpreter lock in custom code?

Sion Arrowsmith siona at chiark.greenend.org.uk
Thu May 11 07:08:03 EDT 2006


Bram Stolk  <bram at geenspam.sara.nl> wrote:
>I've implemented, in C, a function that does a lot of I/O, and thus
>can block for a long time.
>
>If I execute this function in my Python script, it does not 
>relinquish the global interpreter lock, like Python's native
>blocking functions do, like I/O funcs, and time.sleep() func.
>
>How can I have my func release the lock?

http://docs.python.org/api/threads.html is the first hit on
searching docs.python.org for "global interpreter lock". It
says:

"""
This is so common that a pair of macros exists to simplify it:

	Py_BEGIN_ALLOW_THREADS
	...Do some blocking I/O operation...
	Py_END_ALLOW_THREADS
"""

-- 
\S -- siona at chiark.greenend.org.uk -- http://www.chaos.org.uk/~sion/
  ___  |  "Frankly I have no feelings towards penguins one way or the other"
  \X/  |    -- Arthur C. Clarke
   her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump



More information about the Python-list mailing list