[Twisted-Python] socket error 22

glyph at divmod.com glyph at divmod.com
Tue May 6 16:00:17 MDT 2008

On 02:43 pm, wthie at thiengineering.ch wrote:
>Hi all

Hi Werner!  Thanks for reporting this issue.  It's always nice to hear 
about problems under high load.  I hope we can get it fixed.
>Running on twisted 2.5 OpenBSD I see the following traceback in the 
>logs every twenty minutes with up to 200 athena/LivePages connected:

>         return address.IPv4Address('TCP', *(self.socket.getsockname() + 
>       File "<string>", line 1, in getsockname
>     socket.error: (22, 'Invalid argument')

>Changing reactors does not help, the error is very unspecific. Before I 
>start changing the source sprinkling it with log statements is there 
>anybody out there who has a cure or knows an explanation.

We don't have an OpenBSD buildbot, so I don't know if this is a 
platform-specific issue.  Can you reproduce it on Linux or FreeBSD, for 
which there are officially-supported buildbots on 
http://buildbot.twistedmatrix.com/supported?branch=trunk ?

One possible issue here is that the POSIX standard says that getsockname 
may fail with EINVAL if the socket has been shut down:


but Linux says that it may fail with EINVAL only if the namelen 
parameter is invalid:


However, it seems wrong that openbsd would shut down the socket without 
giving some other notification (the usual stuff that Twisted uses to get 
notified of a socket shutting down; presence in the write-selected set, 
an error in send() or recv()); i.e. you should see connectionLost called 
before this error can occur.

If you really want to run Twisted on OpenBSD though, the first step 
should be getting a buildbot going and submitting any patches for failed 
tests.  Otherwise any suggestions from core developers are just going to 
be guesses...

More information about the Twisted-Python mailing list