|
Re: Callbacks from other threads (crash in PyGILState_Release): msg#00034python.pyrex
Geoff Schmidt <gschmidt@xxxxxxxxxxxx> writes: > > I tried adding the extra PyEval_Save/RestoreThread that you show in > your example, but I still get the same segfault. The revised code is > below. Could you take a look and tell me if I understood your advise? > I think you need to call PyEval_InitThreads() before pthread_create. void PyEval_InitThreads( ) "Initialize and acquire the global interpreter lock. It should be called in the main thread before creating a second thread or engaging in any other thread operations such as PyEval_ReleaseLock() or PyEval_ReleaseThread(tstate). It is not needed before calling PyEval_SaveThread() or PyEval_RestoreThread()." ... "When only the main thread exists, no lock operations are needed. This is a common situation (most Python programs do not use threads), and the lock operations slow the interpreter down a bit. Therefore, the lock is not created initially." Jani Hakala |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Callbacks from other threads (crash in PyGILState_Release): 00034, Geoff Schmidt |
|---|---|
| Next by Date: | Re: Callbacks from other threads (crash in PyGILState_Release): 00034, Geoff Schmidt |
| Previous by Thread: | Re: Callbacks from other threads (crash in PyGILState_Release)i: 00034, Geoff Schmidt |
| Next by Thread: | Re: Callbacks from other threads (crash in PyGILState_Release): 00034, Geoff Schmidt |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |