Skip to content

Handling of EPROTOTYPE in cherrypy.wsgiserver #1392

Description

Originally reported by: Florian Bruhin (Bitbucket: The-Compiler, GitHub: The-Compiler)


I'm running wsgiserver3 standalone (to run httpbin for end-to-end tests for qutebrowser) as part of a CI infrastructure.

I noticed I'm getting this on OS X Yosemite a lot (all 5 runs or so?):

socket.error 41
Traceback (most recent call last):
  File "lib/python3.5/site-packages/cherrypy/wsgiserver/wsgiserver3.py", line 1068, in communicate
    req.respond()
  File "lib/python3.5/site-packages/cherrypy/wsgiserver/wsgiserver3.py", line 856, in respond
    self.server.gateway(self).respond()
  File "lib/python3.5/site-packages/cherrypy/wsgiserver/wsgiserver3.py", line 1970, in respond
    self.write(chunk)
  File "lib/python3.5/site-packages/cherrypy/wsgiserver/wsgiserver3.py", line 2042, in write
    self.req.write(chunk)
  File "lib/python3.5/site-packages/cherrypy/wsgiserver/wsgiserver3.py", line 904, in write
    self.conn.wfile.write(chunk)
  File "lib/python3.5/site-packages/cherrypy/wsgiserver/wsgiserver3.py", line 1001, in write
    self._flush_unlocked()
  File "lib/python3.5/site-packages/cherrypy/wsgiserver/wsgiserver3.py", line 1010, in _flush_unlocked
    n = self.raw.write(bytes(self._write_buf))
  File "lib/python3.5/socket.py", line 589, in write
    return self._sock.send(b)
OSError: [Errno 41] Protocol wrong type for socket

I did some research, and it seems like OS X has a kernel bug which causes it to return EPROTOTYPE instead of EPIPE sometimes.

libev fixed this by retrying on EPROTOTYPE (in the hope to get EPIPE then), while Tornado treats it like ECONNRESET.

I can try and submit a PR for this, but I'm not sure what the best way to fix this is - just adding EPROTOTYPE to socket_errors_to_ignore if on OS X?

Also, would it be possible to have a new release somewhen soon-ish after the fix is in?


Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions