On May 16, 2005, at 2:39 PM, Ronald Oussoren wrote: > > On 16-mei-2005, at 21:28, [EMAIL PROTECTED] wrote: > >> The problem isn't the Cocoa threads (Cocoa knows that the >> application is multithreaded). The problem is that the python >> code that is executing in a threading.Thread calls >> performSelectorOnMainThread to do the UI on the main thread >> (which, since waits for that to complete, blocking the >> interpreter). The selector called in turn tries to interpret >> additional Python code, but can't because the lock is held by the >> blocked threading.Thread and a simple case of deadlock occurs. >> > > That should never occur. All calls into ObjC should give up the > GIL. That is, during 'performSelectorOnMainThread' the GIL should > be free for the taking, and the mail thread should be able to pick > it up. If that doesn't work you ran into a bug in PyObjC (or python > itself, we have had problems with GIL-related code in the past). > You'd run into the same problem using NSThread. >
I'm more than willing to admit that there is some other problem here with threading, GIL, etc... and that what I'm seeing is only another symptom of that bigger problem, because I just discovered that if I do the "debug using the local interpreter and absolutely no extra threads ever generated for anything" I get: Fatal Python error: PyThreadState_Get: no current thread so it's probably something bad as a result of updating to Tiger (I know there was a perfectly fine main thread which way up the call chain responded to the menu command to start debugging, executed a boatload of python code, and then loaded a NIB and in that awakeFromNib a call to PyImport_AddModule sent it screaming down to SIGABRT land): #0 0x9004a10c in kill () #1 0x90120934 in abort () #2 0x9879d774 in Py_FatalError () #3 0x9879a884 in PyThreadState_Get () #4 0x98791f48 in PyImport_GetModuleDict () #5 0x98792708 in PyImport_AddModule () #6 0x00008858 in -[PyInteractive awakeFromNib] (self=0x5800fa0, _cmd=0x0) at /Volumes/YWork1/PyOXIDE/Source/PyInteractive.mm:130 #7 0x92886788 in -[NSSet makeObjectsPerformSelector:] () #8 0x93636174 in -[NSIBObjectData nibInstantiateWithOwner:topLevelObjects:] () #9 0x9370cdc4 in old_loadNib () #10 0x93621fd0 in +[NSBundle(NSNibLoading) _loadNibFile:nameTable:withZone:ownerBundle:] () #11 0x9367923c in +[NSBundle(NSNibLoading) loadNibFile:externalNameTable:withZone:] () #12 0x9370cb68 in -[NSWindowController loadWindow] () #13 0x9370c88c in -[NSWindowController window] () #14 0x04a008f8 in _ffi_call_DARWIN () at /Users/ronald/Projects/ pyobjc-1.2/pyobjc/libffi-src/src/powerpc/darwin.S:118 #15 0x04a002ec in ffi_call (cif=0x0, fn=0x39, rvalue=0xa00042b0, avalue=0xffffffff) at /Users/ronald/Projects/pyobjc-1.2/pyobjc/libffi- src/src/powerpc/ffi_darwin.c:395 #16 0x049ebeac in PyObjCFFI_Caller (aMeth=0x5754368, self=0x5145d10, args=0x0) at Modules/objc/libffi_support.m:1228 #17 0x049fca24 in objcsel_call (self=0x5754368, args=0x1759030) at Modules/objc/selector.m:502 #18 0x9871e8e0 in PyObject_Call () #19 0x9877e35c in PyEval_GetFuncDesc () #20 0x9877dd4c in PyEval_GetFuncDesc () #21 0x9877b414 in PyEval_EvalCode () #22 0x9877c5e4 in PyEval_EvalCodeEx () #23 0x98733530 in PyFunction_SetClosure () #24 0x9871e8e0 in PyObject_Call () #25 0x049fd1dc in pysel_call (self=0x5130060, args=0x0, kwargs=0x0) at Modules/objc/selector.m:958 #26 0x9871e8e0 in PyObject_Call () #27 0x9877e35c in PyEval_GetFuncDesc () #28 0x9877dd4c in PyEval_GetFuncDesc () #29 0x9877b414 in PyEval_EvalCode () #30 0x9877dedc in PyEval_GetFuncDesc () #31 0x9877dd34 in PyEval_GetFuncDesc () #32 0x9877b414 in PyEval_EvalCode () #33 0x9877c5e4 in PyEval_EvalCodeEx () #34 0x9877df90 in PyEval_GetFuncDesc () #35 0x9877dd34 in PyEval_GetFuncDesc () #36 0x9877b414 in PyEval_EvalCode () #37 0x9877dedc in PyEval_GetFuncDesc () #38 0x9877dd34 in PyEval_GetFuncDesc () #39 0x9877b414 in PyEval_EvalCode () #40 0x9877c5e4 in PyEval_EvalCodeEx () #41 0x98733530 in PyFunction_SetClosure () #42 0x9871e8e0 in PyObject_Call () #43 0x98726af4 in PyMethod_New () #44 0x9871e8e0 in PyObject_Call () #45 0x9871eb8c in PyObject_CallMethod () #46 0x0000b450 in -[NSDocument(NSDocumentPyHandler) pythonOnHandler:] (self=0x512e1c0, _cmd=0x0, sender=0xa00042b0) at /Volumes/YWork1/ PyOXIDE/Source/NSDocumentPyHandler.mm:181 #47 0x936bd274 in -[NSApplication sendAction:to:from:] () #48 0x93717a70 in -[NSMenu performActionForItemAtIndex:] () #49 0x937177f4 in -[NSCarbonMenuImpl performActionWithHighlightingForItemAtIndex:] () #50 0x9371729c in -[NSMenu performKeyEquivalent:] () #51 0x93716e7c in -[NSApplication _handleKeyEquivalent:] () #52 0x93620c70 in -[NSApplication sendEvent:] () #53 0x936185d0 in -[NSApplication run] () #54 0x93708e04 in NSApplicationMain () #55 0x00007944 in _start (argc=1, argv=0xbffff99c, envp=0xbffff9a4) at /SourceCache/Csu/Csu-46/crt.c:267 #56 0x000077b8 in start () > It would be really helpful if you could test using PyObjC SVN head > both with Python 2.3 and with Python 2.4. > It's on the list. Glenn Andreas [EMAIL PROTECTED] <http://www.gandreas.com/> oh my! quadrium | build, mutate, evolve | images, textures, backgrounds, art _______________________________________________ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig