has <hengist.p...@virgin.net> wrote: > ...or prevent the OS from automatically upgrading your > python process to a GUI process (which it only does if it knows the > executable is located in an application bundle, e.g. Python.app/ > Contents/MacOS/python).
Thanks! I'm not running Python.app -- I'm running /usr/bin/python, which if I follow the symlinks leads me to /System/Library/Frameworks/Python.framework/Versions/2.5/bin/python2.5, which in turn "file" shows to be a dual-architecture executable, which in my case is "Mach-O executable i386". So I don't see how this rule about automatic upgrading really applies -- I'm not using Python.app. Perhaps it's not the OS "upgrading" the process, but rather some code in some extension calling "TransformProcessType" (http://www.cocoadev.com/index.pl?TransformProcessType)? And I still don't see how to fix the logout/shutdown problem. The Apple Cocoa document on this, http://developer.apple.com/documentation/Cocoa/Conceptual/AppArchitecture/Tasks/GracefulAppTermination.html, seems to say "In Cocoa, all raw events requiring application termination result in the invocation of the NSApplication delegation method applicationShouldTerminate:. If the delegate does not implement this method, the application is terminated regardless of any unsaved documents." Presumably, my script doesn't implement this method, and thus "the application is terminated". How? Is it as simple as installing a SIGTERM handler? Bill > Bill Janssen wrote: > > > We discussed this a bit last year, but with no resolution that I > > remember. I've got a situation where a Python program is preventing > > logout/shutdown. It's a script that just runs in an endless loop > > watching what app I'm working with; when it sees one it knows > > (Preview, > > MS Word, Safari, etc.) it uses appscript to ask the app what document > > I'm looking at. It then squirrels that document away in a journal so > > that I've got a record of what I've been working with. > > > > The basic control loop is something like this: > > > > while True: > > ... see what's running, and possibly what document ... > > time.sleep(1.0) > > > See: > > http://mail.python.org/pipermail/pythonmac-sig/2008-December/020792.html > > Two options described there: replace your 'while True' loop with a > Carbon/Cocoa event loop, allowing a GUI-based process to handle > incoming events, or prevent the OS from automatically upgrading your > python process to a GUI process (which it only does if it knows the > executable is located in an application bundle, e.g. Python.app/ > Contents/MacOS/python). > > Regards, > > has _______________________________________________ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig