[Twisted-Python] _twistd_unix.py / daemonize() / OSX / USING_FORK_WITHOUT_EXEC_IS_NOT_SUPPORTED_BY_FILE_MANAGER

James Y Knight foom at fuhm.net
Wed Oct 13 13:20:20 EDT 2010

On Oct 13, 2010, at 12:05 PM, Erik van Blokland wrote:

> On Oct 13, 2010, at 5:52 PM, Phil Mayers wrote:
>> Other info indicates this is Apple trying to be clever and "protect" 
>> applications from some signal handling issues surrounding fork() with 
>> libraries which aren't safe in that situation; presumably these are 
>> MacOS-specific libraries?
>> If this really is true, then MacOS X is no longer posix-compliant in 
>> those circumstances, and Twisted is going to need some work :o(
>> Can you share more details about the application; the context in which 
>> it is started, and which system libraries it's likely to load?
> Here's a compact version. The script uses OSX' Quartz to create and manipulate images. Twisted is used to wrap it as a webserver, images are served. More pointers on how to start and use it in the script itself.

You need to avoid using or importing any OSX APIs until after the daemonization has occurred. Unfortunately, twisted executes the entire script file before daemonizing. [that's unfortunate for other reasons besides this, too]

Here's a corrected version of your script which works properly. It defers importing Quartz until the reactor is running, by moving it into a function called by reactor.callWhenRunning().

-------------- next part --------------
A non-text attachment was scrubbed...
Name: twisted.quartz.test.py
Type: text/x-python-script
Size: 5042 bytes
Desc: not available
Url : http://twistedmatrix.com/pipermail/twisted-python/attachments/20101013/452e4763/attachment.bin 

More information about the Twisted-Python mailing list