[Twisted-Python] multiple workers

Hello I try to write twisted based daemon that work in multiple workers, like this: from twisted.internet import reactor; from proxy import FASTCGIServerProxyFactory; import os; reactor.listenUNIX("/tmp/twisted-fcgi.sock", FASTCGIServerProxyFactory()); for i in xrange(3): l_pid = os.fork(); if(l_pid == 0): break; reactor.run() I creatae 4 wokers(by num of CPU cores). Im my test all ok, but when i shutdown daemon i got follow error 3 times (because every worker try to unlink sock file: /tmp/twisted-fcgi.sock): Traceback (most recent call last): File "/usr/local/lib/python2.6/site-packages/twisted/internet/defer.py", line 249, in addCallbacks self._runCallbacks() File "/usr/local/lib/python2.6/site-packages/twisted/internet/defer.py", line 441, in _runCallbacks self.result = callback(self.result, *args, **kw) File "/usr/local/lib/python2.6/site-packages/twisted/internet/base.py", line 426, in _continueFiring callable(*args, **kwargs) File "/usr/local/lib/python2.6/site-packages/twisted/internet/base.py", line 613, in disconnectAll failure.Failure(main.CONNECTION_LOST)) --- <exception caught here> --- File "/usr/local/lib/python2.6/site-packages/twisted/python/log.py", line 84, in callWithLogger return callWithContext({"system": lp}, func, *args, **kw) File "/usr/local/lib/python2.6/site-packages/twisted/python/log.py", line 69, in callWithContext return context.call({ILogContext: newCtx}, func, *args, **kw) File "/usr/local/lib/python2.6/site-packages/twisted/python/context.py", line 59, in callWithContext return self.currentContext().callWithContext(ctx, func, *args, **kw) File "/usr/local/lib/python2.6/site-packages/twisted/python/context.py", line 37, in callWithContext return func(*args,**kw) File "/usr/local/lib/python2.6/site-packages/twisted/internet/unix.py", line 134, in connectionLost os.unlink(self.port) exceptions.OSError: [Errno 2] No such file or directory: '/tmp/twisted-fcgi.sock' So my questions is How can i suppress this behaviour, so shutdown code executes only once in main process?

On 1 Sep, 10:53 pm, ruslan.usifov@gmail.com wrote:
Using fork this way isn't supported. Either fork before you import any Twisted modules, or use reactor.spawnProcess to create workers instead. If you must share a single listening socket amongst all the workers, you might be interested in <http://twistedmatrix.com/trac/ticket/4387>. Jean-Paul

On 1 Sep, 10:53 pm, ruslan.usifov@gmail.com wrote:
Using fork this way isn't supported. Either fork before you import any Twisted modules, or use reactor.spawnProcess to create workers instead. If you must share a single listening socket amongst all the workers, you might be interested in <http://twistedmatrix.com/trac/ticket/4387>. Jean-Paul
participants (2)
-
exarkun@twistedmatrix.com
-
ruslan usifov