[python-win32] WSAAsyncSelect

Tim Roberts timr at probo.com
Fri Jan 7 23:44:11 CET 2011


david.briant at ubs.com wrote:
> I'm looking for how to do blocking calls. If I do a blocking call into a
> dll and don't release the GIL the whole of python is blocked!!!
>
> It says in the C-API whenever you call into a C-DLL with a blocking call
> you need to release the GIL i.e. the Py_BEGIN_ALLOW_THREADS macro, and
> when the call returns you need to relock the GIL i.e.
> Py_END_ALLOW_THREADS.
>
> So want to know how to release and acquire the GIL from pure python
> (i.e. via ctypes or win32).

That's impossible.  The whole point of releasing the GIL is to say "I
hereby promise I won't be interpreting any Python code until I reacquire
the lock".  If you could do that from Python code itself, you would
create a singularity that will suck in the solar system.

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the python-win32 mailing list