Re: [Pythonmac-SIG] question about garbage collection with NSApplication.run()
Thanks, Ronald. Bill Ronald Oussoren wrote: > > On 31 May, 2009, at 20:34, Bill Janssen wrote: > > > I'm writing a Python program that has a main that looks like this: > > > >application = NSApplication.sharedApplication() > > > ># set up handler for network change notification > >SCDynamicStoreSetNotificationKeys(DYNSTORE, None, > > [NETWORK_KEY,]) > ># Get a CFRunLoopSource for our store session and add it to > > the application's runloop: > >CFRunLoopAddSource( > >NSRunLoop.currentRunLoop().getCFRunLoop(), > >SCDynamicStoreCreateRunLoopSource(None, DYNSTORE, 0), > >kCFRunLoopCommonModes > >) > > > ># add a timer for application scan events > >timer = NSTimer > > .scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_( > >periodicity, scanner, objc.selector(scanner.scan, > > signature="v@:"), None, True) > > > ># using an NSRunLoop avoids Activity Monitor complaining > > about "not responding" > >application.run() > > > > Do I need to do anything about NSAutoreleasePools? My understanding > > is > > that this is single-threaded, and that NSApplication.run will handle > > periodic drainage of the default main thread release pool. > > That's right. NSApplication.run manages the the pool for you. You only > have to worry about autorelease pools when you create new threads > running Cocoa code, and when you a long time without looping through > the eventloop. > > Ronald > ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] question about garbage collection with NSApplication.run()
On 31 May, 2009, at 20:34, Bill Janssen wrote: I'm writing a Python program that has a main that looks like this: application = NSApplication.sharedApplication() # set up handler for network change notification SCDynamicStoreSetNotificationKeys(DYNSTORE, None, [NETWORK_KEY,]) # Get a CFRunLoopSource for our store session and add it to the application's runloop: CFRunLoopAddSource( NSRunLoop.currentRunLoop().getCFRunLoop(), SCDynamicStoreCreateRunLoopSource(None, DYNSTORE, 0), kCFRunLoopCommonModes ) # add a timer for application scan events timer = NSTimer .scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_( periodicity, scanner, objc.selector(scanner.scan, signature="v@:"), None, True) # using an NSRunLoop avoids Activity Monitor complaining about "not responding" application.run() Do I need to do anything about NSAutoreleasePools? My understanding is that this is single-threaded, and that NSApplication.run will handle periodic drainage of the default main thread release pool. That's right. NSApplication.run manages the the pool for you. You only have to worry about autorelease pools when you create new threads running Cocoa code, and when you a long time without looping through the eventloop. Ronald smime.p7s Description: S/MIME cryptographic signature ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
[Pythonmac-SIG] question about garbage collection with NSApplication.run()
I'm writing a Python program that has a main that looks like this: application = NSApplication.sharedApplication() # set up handler for network change notification SCDynamicStoreSetNotificationKeys(DYNSTORE, None, [NETWORK_KEY,]) # Get a CFRunLoopSource for our store session and add it to the application's runloop: CFRunLoopAddSource( NSRunLoop.currentRunLoop().getCFRunLoop(), SCDynamicStoreCreateRunLoopSource(None, DYNSTORE, 0), kCFRunLoopCommonModes ) # add a timer for application scan events timer = NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_( periodicity, scanner, objc.selector(scanner.scan, signature="v@:"), None, True) # using an NSRunLoop avoids Activity Monitor complaining about "not responding" application.run() Do I need to do anything about NSAutoreleasePools? My understanding is that this is single-threaded, and that NSApplication.run will handle periodic drainage of the default main thread release pool. Bill ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig