from Foundation import * import threading class MyObject (NSObject): def myMethod_(self, dummy): print dummy raise RuntimeError("hello") obj = MyObject.new() class MyThread(threading.Thread): def run(self): while True: pool = NSAutoreleasePool.alloc().init() print "Doit!" obj.performSelectorOnMainThread_withObject_waitUntilDone_( 'myMethod:', [], True) print "Result is in" del pool t = MyThread() t.setDaemon(1) t.start() loop = NSRunLoop.currentRunLoop() try: loop.run() except: print "Exception!" print "Ready!"