[Python-Dev] Problem with PyGILState_Ensure() and the thread Module

Phil Thompson phil at riverbankcomputing.co.uk
Mon Aug 16 21:57:41 CEST 2004


I'm having a problem calling functions in a C extension module that uses 
PyGILState_Ensure() and PyGILState_Release() from a thread created with 
thread.start_new_thread().

A deadlock occurs in PyGILState_Ensure() because it doesn't know anything 
about the thread state created by start_new_thread(). Therefore it creates a 
new one and then calls PyEval_RestoreThread() - but it already holds the GIL 
and so deadlocks.

I would expect the threading PyGILState_Ensure() to know about all thread 
states - not just the ones it creates itself.

Is this a bug, feature, or misunderstanding on my part?

This is with Python 2.4a2.

Thanks,
Phil


More information about the Python-Dev mailing list

Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant