|
Re: Callbacks from other threads (crash in PyGILState_Release): msg#00037python.pyrex
Hi Geoff, Geoff Schmidt wrote: > My understanding of the docs was that PyEval_SaveThread effectively > suspend the thread (from Python's perspective) so that another function > had a chance to gain access to the interpreter by calling > PyEval_RestoreThread or PyGILState_Ensure, and that > PyGILState_Ensure/Release was basically PyEval_Save/RestoreThread plus > logic to create and destroy thread states if necessary. Is this > understanding correct? Sounds correct. >> cdef PyThreadState *state >> state = PyEval_SaveThread() >> function_that_calls_callback_in_thread(callback) >> PyEval_RestoreThread(state) > > My function_that_calls_callback_in_thread() returns immediately, so I > didn't think PyEval_Save/RestoreThread was necessary Right, then it's of no use here. The way we use it is having threaded C code that calls into Python from within the function call above. That's why it makes sense for us to call save/restoreThread. If the interpreter is to be called out-of-order, all you should need to do is make sure InitThreads was called (as Jani suggested). Stefan |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | pix compilation dependencies with distutils: 00037, Fabien Cromières |
|---|---|
| Next by Date: | Struggling with "Hello World" Extension type: 00037, Andrew Chambers |
| Previous by Thread: | Re: Callbacks from other threads (crash in PyGILState_Release)i: 00037, Geoff Schmidt |
| Next by Thread: | pix compilation dependencies with distutils: 00037, Fabien Cromières |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |