[Twisted-Python] file descriptor cannot be a negative integer (-1)
![](https://secure.gravatar.com/avatar/dcf0a20d957dbeed0f6b8958ea92aa96.jpg?s=120&d=mm&r=g)
Hello! I have use kqreactor from this branch http://twistedmatrix.com/trac/browser/branches/kqreactor-1918-3/. In the follow code we connect to unix socket. Sometimes we got the error: "file descriptor cannot be a negative integer (-1)" what does this mean? I haven't any ideas l_client = protocol.ClientCreator(reactor, Proxy); l_client.connectUNIX(self.factory.proxysock).addCallback(connectionMade).addErrback(cantConnect); PS: my uname -a is: FreeBSD 8.0-RELEASE-p2 FreeBSD 8.0-RELEASE-p2 #2: Wed Jan 13 17:50:25 UTC 2010 root@DTG1383:/usr/obj/usr/src/sys/Z-AMD64 amd64
![](https://secure.gravatar.com/avatar/607cfd4a5b41fe6c886c978128b9c03e.jpg?s=120&d=mm&r=g)
On 09:50 pm, ruslan.usifov@gmail.com wrote:
Hello!
I have use kqreactor from this branch http://twistedmatrix.com/trac/browser/branches/kqreactor-1918-3/. In the follow code we connect to unix socket. Sometimes we got the error: "file descriptor cannot be a negative integer (-1)" what does this mean? I haven't any ideas
l_client = protocol.ClientCreator(reactor, Proxy); l_client.connectUNIX(self.factory.proxysock).addCallback(connectionMade).addErrback(cantConnect);
PS: my uname -a is: FreeBSD 8.0-RELEASE-p2 FreeBSD 8.0-RELEASE-p2 #2: Wed Jan 13 17:50:25 UTC 2010 root@DTG1383:/usr/obj/usr/src/sys/Z-AMD64 amd64
It means there's a bug somewhere in your code or in the reactor. If you can reproduce the problem with a simple example, it might be useful in fixing the problem. Jean-Paul
![](https://secure.gravatar.com/avatar/dcf0a20d957dbeed0f6b8958ea92aa96.jpg?s=120&d=mm&r=g)
Sorry fo my question. I'm new in twisted ad may misunderstand some things:-), and my questions may look like trivial I have follow stack trace: cant connect to fcgi socket: [Failure instance: Traceback: <type 'exceptions.ValueError'>: file descriptor can not be a negative integer (-1) /usr/local/lib/python2.6/site-packages/twisted/internet/base.py:796:runUntilCurrent /usr/local/lib/python2.6/site-packages/twisted/internet/protocol.py:184:fire /usr/local/lib/python2.6/site-packages/twisted/internet/defer.py:318:callback /usr/local/lib/python2.6/site-packages/twisted/internet/defer.py:424:_startRunCallbacks --- <exception caught here> --- /usr/local/lib/python2.6/site-packages/twisted/internet/defer.py:441:_runCallbacks /usr/local/fastcgi-0.1/fcgi/proxy.py:124:connectionMade /usr/local/lib/python2.6/site-packages/twisted/internet/abstract.py:340:resumeProducing /usr/local/lib/python2.6/site-packages/twisted/internet/abstract.py:278:startReading /usr/local/lib/python2.6/site-packages/twisted/internet/kqreactor.py:82:addReader /usr/local/lib/python2.6/site-packages/twisted/internet/kqreactor.py:71:_updateRegistration ] My connectionMade function looks like this: def connectionMade(protocol): protocol._setPeer(self); self._setPeer(protocol); for chunk in self._chunks: protocol.transport.write(chunk); self._chunks = []; self.transport.resumeProducing(); All code that i use look like this: def proxy(self): def connectionMade(protocol): protocol._setPeer(self); self._setPeer(protocol); for chunk in self._chunks: protocol.transport.write(chunk); self._chunks = []; self.transport.resumeProducing(); def cantConnect(fail): log.err("cant connect to fcgi socket: %s" % (fail.getErrorMessage())); self.transport.loseConnection(); #устанавливаем соединение с реальным обработчиком (в нашем случае это php) self.transport.pauseProducing(); l_client = protocol.ClientCreator(reactor, Proxy); l_client.connectUNIX(self.factory.proxysock).addCallback(connectionMade).addErrback(cantConnect); Its a simply fastcgi proxy, which reads all request(analize it, do some pending things and then proxy request to real worker) Thank for your help. PS: i use kqreactor.py from this branch http://twistedmatrix.com/trac/browser/branches/kqreactor-1918-3/
![](https://secure.gravatar.com/avatar/e1554622707bedd9202884900430b838.jpg?s=120&d=mm&r=g)
On Sep 17, 2010, at 8:21 PM, ruslan usifov wrote:
Its a simply fastcgi proxy, which reads all request(analize it, do some pending things and then proxy request to real worker)
I am very curious about your problem, but I cannot help you with it with the incomplete snippets you have provided. Can you reduce your program to a smaller test program that produces this traceback? Here is a guide to producing a useful example: <http://sscce.org/>
Thank for your help.
Thanks for reporting the bug. I hope you can provide us with enough information to get it fixed :).
PS: i use kqreactor.py from this branch http://twistedmatrix.com/trac/browser/branches/kqreactor-1918-3/
If you use the kqreactor.py from <http://trac.calendarserver.org/browser/CalendarServer/trunk/twext/internet/k...>, does it make any difference, or do you still see the same traceback?
![](https://secure.gravatar.com/avatar/dcf0a20d957dbeed0f6b8958ea92aa96.jpg?s=120&d=mm&r=g)
I implement specific proxy server, so after analyze i think that this happens if client disconnected from server, but server already made connection to proxied service, so call resumeProducing() (in connectionMade ), throws exception (because socket already closed) "file descriptor can not be a negative integer (-1)" So this looks like my bug 2010/9/20 Glyph Lefkowitz <glyph@twistedmatrix.com>
On Sep 17, 2010, at 8:21 PM, ruslan usifov wrote:
Its a simply fastcgi proxy, which reads all request(analize it, do some pending things and then proxy request to real worker)
I am very curious about your problem, but I cannot help you with it with the incomplete snippets you have provided. Can you reduce your program to a smaller test program that produces this traceback?
Here is a guide to producing a useful example: <http://sscce.org/>
Thank for your help.
Thanks for reporting the bug. I hope you can provide us with enough information to get it fixed :).
PS: i use kqreactor.py from this branch http://twistedmatrix.com/trac/browser/branches/kqreactor-1918-3/
If you use the kqreactor.py from < http://trac.calendarserver.org/browser/CalendarServer/trunk/twext/internet/k...>, does it make any difference, or do you still see the same traceback?
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
![](https://secure.gravatar.com/avatar/e1554622707bedd9202884900430b838.jpg?s=120&d=mm&r=g)
On Sep 20, 2010, at 10:34 AM, ruslan usifov wrote:
I implement specific proxy server, so after analyze i think that this happens if client disconnected from server, but server already made connection to proxied service, so call resumeProducing() (in connectionMade ), throws exception (because socket already closed) "file descriptor can not be a negative integer (-1)"
So this looks like my bug
I think I understand what you mean, but could you express this as a simple Python program rather than an english sentence, so that I can be sure? Thanks!
![](https://secure.gravatar.com/avatar/dcf0a20d957dbeed0f6b8958ea92aa96.jpg?s=120&d=mm&r=g)
ok i provide sample till the end of this week 2010/9/20 Glyph Lefkowitz <glyph@twistedmatrix.com>
On Sep 20, 2010, at 10:34 AM, ruslan usifov wrote:
I implement specific proxy server, so after analyze i think that this happens if client disconnected from server, but server already made connection to proxied service, so call resumeProducing() (in connectionMade ), throws exception (because socket already closed) "file descriptor can not be a negative integer (-1)"
So this looks like my bug
I *think* I understand what you mean, but could you express this as a simple Python program rather than an english sentence, so that I can be sure?
Thanks!
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
participants (3)
-
exarkun@twistedmatrix.com
-
Glyph Lefkowitz
-
ruslan usifov