[Twisted-Python] multiple workers

ruslan usifov ruslan.usifov at gmail.com
Wed Sep 1 18:53:50 EDT 2010


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?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-python/attachments/20100902/c70a3642/attachment.htm 


More information about the Twisted-Python mailing list