[Pythonmac-SIG] Python threading.Thread vs PyObjC performOnMainThread
Ronald Oussoren
ronaldoussoren at mac.com
Mon May 16 21:12:11 CEST 2005
On 16-mei-2005, at 20:53, gandreas at gandreas.com wrote:
>>
>> NO! That is really really horribly bad to do. Working around a
>> bug in PyObjC by writing code that will break in correct versions
>> of PyObjC is absolutely horrible. You should NEVER release the
>> lock unless you own it.
>>
>>
>
> Here, then, is probably the heart of the problem - the interactions
> between python threads spawned by threading.Thread and the main
> (objc) thread and performSelectorOnMainThread are "undefined", and
> the more I look at it, the more it appears that using
> threading.Thread in a PyObjC app is a bad idea and should probably
> just be chalked up as "unsupported and probably won't work". It
> appears that I'd need to build something on top of NSThread (in
> Objective-C) with explicit thread state handling to get this to work
> consistently and correctly.
Threading.Thread should work as long as Cocoa knows that the
application is
multithreaded or you don't call Cocoa outside of the main thread. (See
http://developer.apple.com/documentation/Cocoa/Conceptual/
Multithreading/index.html#//apple_ref/doc/uid/10000057i,
threading.Thread uses POSIX threads)
Using NSThread is slightly cleaner if you do call Cocoa API's from
secondairy threads.
Ronald
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2105 bytes
Desc: not available
Url : http://mail.python.org/pipermail/pythonmac-sig/attachments/20050516/4f431701/smime.bin
More information about the Pythonmac-SIG
mailing list