Re: [Pyobjc-dev] Web Services Tool example broken
Brought to you by:
ronaldoussoren
From: Bob I. <bo...@re...> - 2004-04-06 14:16:57
|
On Apr 6, 2004, at 3:01 AM, Just van Rossum wrote: > Bob Ippolito wrote: > >> I have no idea how to reasonably debug that example, it freely mixes >> ObjC and Python threading code. It's not even correct for at least >> one reason: it doesn't detach an NSThread anywhere, so Foundation and >> Cocoa are not notified to be thread safeish. Even though it did work >> previously, that might have been by accident. > > Huh? The WST example goes through great pain not to call any GUI code > from the worker threads, so I don't see why Cocoa needs to be notified. > > It's also the first time I hear that pure pthreads would be a no-no in > Cocoa. Is that really so? How do NSThreads cooperate with the threading > module? The thing is that Foundation and Cocoa needs to know about the threads you are using in the same way that Python needs to know about them (via PyGILState_Ensure, etc.). There is a hook and notification that happens in Foundation when you detach your first NSThread (which this program never explicitly does), and you are otherwise supposed to at least call +[NSThread currentThread] from any raw pthread that expects to call Foundation or Cocoa code (which this program also never does). That said, it's probably not WHY it doesn't work, I'm just saying the program isn't strictly correct to begin with, and it uses threads, so it will be hard to debug. -bob |