[Pyobjc-dev] Starting up pyobjc from a cocoa bundle, nsthreads not firing correctly
Brought to you by:
ronaldoussoren
|
From: Gus M. <gus...@gm...> - 2008-06-27 19:51:10
|
I've got a cocoa bundle that I load into my app, which then starts up python using the same technique a standard 10.5 cocoa-python application uses in main.m. The only difference is that my main.py file doesn't call AppHelper.runEventLoop() because the main event loop has already been started by the host (cocoa) application. Everything works great, until I try and use NSThread's detachNewThreadSelector_toTarget_withObject_ from within python. It seems that some sort of runloop needs to be setup or something, but I'm really not sure that that would be. If I call NSApp().run() right after I create my thread, then it fires off and does its work- but then that leaves the rest of my application in a weird state. If I click outside my application and then back, then the thread seems to move forward just a little bit. Any ideas? I've also gone the pure python approach to creating the bundle- and nsthreads work great with this tequnique, but it creates a massive bundle (16MB!) and I'd rather not bloat my app (vs 84KB). Here's what the stack for the thread looks like when it's stalled: Thread 23 (process 27704 thread 0x680f): #0 0x94c1168e in __semwait_signal () #1 0x94c3c986 in _pthread_cond_wait () #2 0x94c3c36d in pthread_cond_wait$UNIX2003 () #3 0x01d5c74c in PyThread_acquire_lock () #4 0x01d336cf in PyEval_RestoreThread () #5 0x14c1885e in PyObjCFFI_Caller () #6 0x14c2fb63 in PyObjCSelector_GetMetadata () #7 0x01ccad3d in PyObject_Call () #8 0x01d38b1a in PyEval_EvalFrameEx () #9 0x01d3a45b in PyEval_EvalCodeEx () #10 0x01ce4c27 in PyFunction_SetClosure () #11 0x01ccad3d in PyObject_Call () #12 0x14c30700 in PyObjCSelector_NewNative () #13 0x01ccad3d in PyObject_Call () #14 0x01d38b1a in PyEval_EvalFrameEx () #15 0x01d3a45b in PyEval_EvalCodeEx () #16 0x01ce4c27 in PyFunction_SetClosure () #17 0x01ccad3d in PyObject_Call () #18 0x14c126d5 in signature_to_ffi_return_type () #19 0x14c01a92 in ffi_prep_cif_machdep () #20 0x90210f1d in -[NSThread main] () #21 0x90210ac4 in __NSThread__main__ () #22 0x94c3b6f5 in _pthread_start () #23 0x94c3b5b2 in thread_start () thanks, -gus |