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

Closed
bb-migration opened this Issue Dec 4, 2015 · 1 comment

Comments

1 participant
@bb-migration

bb-migration 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/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?


@bb-migration

This comment has been minimized.

Show comment
Hide comment
@bb-migration

bb-migration 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.

bb-migration 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.

@jaraco jaraco closed this in 2ad0cb2 Apr 30, 2016

Safihre added a commit to Safihre/cheroot that referenced this issue Jun 17, 2017

Catch "Protocol wrong type for socket" on OSX also for non-blocking s…
…ockets

This was originally fixed for regular sockets in cherrypy/cherrypy#1392
But it seems it can also occur during the sending on non-blocking sockets https://forums.sabnzbd.org/viewtopic.php?f=2&t=22728&p=112251

This is on our build-in CP 8.1.2, but since the code seems identical it can occur in any CP version.

webknjaz added a commit to cherrypy/cheroot that referenced this issue Jun 18, 2017

Ignore EPROTOTYPE @ OSX for non-blocking sockets
* 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: https://forums.sabnzbd.org/viewtopic.php?f=2&t=22728&p=112251
* 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

wiz
Updated py-cheroot to 5.7.0.
v5.7.0
======

- 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

v5.6.0
======

- 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

v5.5.2
======

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

  Ref: sabnzbd/sabnzbd#820

  Ref: sabnzbd/sabnzbd#860

v5.5.1
======

- 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.

  Ref: https://forums.sabnzbd.org/viewtopic.php?f=2&t=22728&p=112251

v5.5.0
======

- #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