[Twisted-Python] Socket error 22, Invalid Argument in twisted/internet/tcp.py
exarkun at divmod.com
Wed Oct 8 13:59:01 EDT 2008
On Wed, 08 Oct 2008 18:57:51 +0200, Werner Thie <wthie at thiengineering.ch> wrote:
>As I wrote in post http://www.mail-archive.com/twisted-
>web at twistedmatrix.com/msg01701.html
>I'm still observing this socket error 22 problem but was not able to dig
>into it any further until now.
>I found the following post from the python mailing list, which seems related
>to my problem:
>Attchached to this post is a small script, which I extended somehow and
>tried out on various platforms:
It looks like these are slightly different cases. The traceback from
Twisted Web comes from using getsockname on a connection the server
accepted. The script you attached calls getsockname on a socket which
has failed to make an outgoing connection. Perhaps they are demonstrating
the same feature/behavior/bug of OpenBSD, but not necessarily. I vaguely
recall trying to investigate the Twisted Web case when you initially raised
it, but I can't remember if I learned anything (I think I recall that I was
not able to reproduce it).
>I agree that this is an Python/OS related question, but what happens with
>the reactor when such an error is thrown?
>Is it harmless or does the system loose resources, wait for timeouts?
When a protocol's dataReceived method raises an exception, the connection
is closed. It seems that this exception is getting all the way from the
request handling code up to beyond the HTTP protocol implementation's
dataReceived method, so that should be what happens for this case. That
means it's probably harmless, but since I don't actually understand the
circumstances under which it happens, I can't say for sure.
>Is a try/except with a normalized answer in the embracing function in
>twisted/internet/tcp.py a possible cure?
You mean in the implementation of getHost()? Maybe, maybe not. I'd like
to understand what OpenBSD thinks it is telling us when it returns EINVAL
>I ask because I experience an unexplainable 'hickup' behavior where the odd
>request which usually triggers an instantaneous response takes up to 30secs
>until a response is seen on the client in a local and clean net enviroment.
It could be that this exception is preventing a request from being processed,
or there could be some other problem, I don't know.
More information about the Twisted-Python