On Sat, May 30, 2009 at 06:17:54PM -0500, travis+ml-twis...@subspacefield.org wrote: > The program works fine normally, and can run in the background, but if I > invoke a daemonize() routine that turns it into a network daemon, it > refuses to serve incoming TCP connections. Actually the TCP connection > is made, but the software never responds to it. > > Specifically, my twisted.internet.protocol.Factory instance is created, > but buildProtocol is never called. > > Before I dive deeply into debugging the software, I thought I'd ask if > anyone knew off the top of their head any reason why Twisted might not > act the same if it was daemonized (no controlling terminal, no > stdin/out/err, forked as a background process).
Here's some behavior I've gathered through debugging. Note that all of the daemonization occurs before starting the reactor. If I don't close any file descriptors during daemonization, the program works fine. If I close all file descriptors (3, 4, 5, 6, 7) and above, it works, but upon disconnecting, I get the following error message: File "/etc/keeper_screen", line 675, in <module> reactor.run() File "/usr/local/lib/python2.5/site-packages/twisted/internet/base.py", line 1128, in run self.mainLoop() --- <exception caught here> --- File "/usr/local/lib/python2.5/site-packages/twisted/internet/base.py", line 1140, in mainLoop self.doIteration(t) File "/usr/local/lib/python2.5/site-packages/twisted/internet/selectreactor.py", line 126, in doSelect self._preenDescriptors() File "/usr/local/lib/python2.5/site-packages/twisted/internet/selectreactor.py", line 88, in _preenDescriptors self._disconnectSelectable(selectable, e, False) File "/usr/local/lib/python2.5/site-packages/twisted/internet/posixbase.py", line 196, in _disconnectSelectable selectable.connectionLost(failure.Failure(why)) File "/usr/local/lib/python2.5/site-packages/twisted/internet/posixbase.py", line 150, in connectionLost os.close(fd) exceptions.OSError: [Errno 9] Bad file descriptor If I close all file descriptors two and above, I get that error message immediately. If I close all file descriptors eight and above, the program works normally. Is there some code in Twisted that expects certain file descriptors to be open? Anyone got a clue what could be happening here? -- Obama Nation | My emails do not have attachments; it's a digital signature that your mail program doesn't understand. | http://www.subspacefield.org/~travis/ If you are a spammer, please email j...@subspacefield.org to get blacklisted.
pgpJOapuCdgEv.pgp
Description: PGP signature
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python