Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling of EPROTOTYPE in cherrypy.wsgiserver #1392

ghost opened this issue Dec 4, 2015 · 1 comment

Handling of EPROTOTYPE in cherrypy.wsgiserver #1392

ghost opened this issue Dec 4, 2015 · 1 comment


Copy link

@ghost ghost commented Dec 4, 2015

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/", line 1068, in communicate
  File "lib/python3.5/site-packages/cherrypy/wsgiserver/", line 856, in respond
  File "lib/python3.5/site-packages/cherrypy/wsgiserver/", line 1970, in respond
  File "lib/python3.5/site-packages/cherrypy/wsgiserver/", line 2042, in write
  File "lib/python3.5/site-packages/cherrypy/wsgiserver/", line 904, in write
  File "lib/python3.5/site-packages/cherrypy/wsgiserver/", line 1001, in write
  File "lib/python3.5/site-packages/cherrypy/wsgiserver/", line 1010, in _flush_unlocked
    n = self.raw.write(bytes(self._write_buf))
  File "lib/python3.5/", 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?

Copy link

@ghost ghost commented Dec 17, 2015

Original comment by Florian Bruhin (Bitbucket: The-Compiler, GitHub: The-Compiler):

Bump? I'm still happy to open a PR if someone can confirm I'm on the right track.

webknjaz added a commit to cherrypy/cheroot that referenced this issue Jun 18, 2017
* EPROTOTYPE == "Protocol wrong type for socket"
* This was originally fixed for regular sockets in cherrypy/cherrypy#1392
* It seems it can also occur during the sending on non-blocking sockets
* Ref:
* Reproducible in CherryPy v8.1.2, but should affect other versions too

PR: #31
Author: @Safihre
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Jul 19, 2017

- CI improvements:
  * Don't run tests during deploy stage
  * Use VM based build job env only for pyenv envs
  * Opt-in for beta trusty image @ Travis CI
  * Be verbose when running tests (show test names)
  * Show xfail/skip details during test run

- #34: Fix ``_handle_no_ssl`` error handler calls

- #21: Fix ``test_conn`` tests:
  * Improve setup_server def in HTTP connection tests
  * Fix HTTP streaming tests
  * Fix HTTP/1.1 pipelining test under Python 3
  * Fix ``test_readall_or_close`` test
  * Fix ``test_No_Message_Body``
  * Clarify ``test_598`` fail reason

- #36: Add GitHub templates for PR, issue && contributing

- #27: Default HTTP Server header to Cheroot version str

- Cleanup _compat functions from server module


- Fix all PEP 257 related errors in all non-test modules.

  ``cheroot/test/*`` folder is only one left allowed to fail with this linter.

- #30: Optimize chunked body reader loop by returning empty data is the size is 0.

  Ref: cherrypy/cherrypy#1602

- Reset buffer if the body size is unknown

  Ref: cherrypy/cherrypy#1486

- Add missing size hint to SizeCheckWrapper

  Ref: cherrypy/cherrypy#1131


- #32: Ignore "unknown error" and "https proxy request" SSL errors.

  Ref: sabnzbd/sabnzbd#820

  Ref: sabnzbd/sabnzbd#860


- Make Appveyor list separate tests in corresponding tab.

- #29: Configure Travis CI build stages.

  Prioritize tests by stages.

  Move deploy stage to be run very last after all other stages finish.

- #31: Ignore "Protocol wrong type for socket" (EPROTOTYPE) @ OSX for non-blocking sockets.

  This was originally fixed for regular sockets in cherrypy/cherrypy#1392.



- #17 via #25: Instead of a read_headers function, cheroot now
  supplies a HeaderReader class to perform the same function.

  Any HTTPRequest object may override the header_reader attribute
  to customize the handling of incoming headers.

  The server module also presents a provisional implementation of
  a DropUnderscoreHeaderReader that will exclude any headers
  containing an underscore. It remains an exercise for the
  implementer to demonstrate how this functionality might be
  employed in a server such as CherryPy.

- #26: Configured TravisCI to run tests under OS X.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

No branches or pull requests

0 participants