Repository navigation
Closed
Description
Originally reported by: Tim Miller (Bitbucket: lashni, GitHub: Unknown)
http://docs.cherrypy.org/en/latest/advanced.html#no-need-for-the-wsgi-interface
Error is encountered when the example code from the link above is run under a python 3.4.3 virtualenv on archlinux, traceback triggers when the server is accessed. Error doesn't occur with python 2.7.10.
Happens with both current head and CherryPy 3.8.0.
[19/Jul/2015:17:41:01] ENGINE Listening for SIGUSR1.
[19/Jul/2015:17:41:01] ENGINE Listening for SIGTERM.
[19/Jul/2015:17:41:01] ENGINE Listening for SIGHUP.
[19/Jul/2015:17:41:01] ENGINE Bus STARTING
CherryPy Checker:
The Application mounted at '' has an empty config.
[19/Jul/2015:17:41:01] ENGINE Started monitor thread '_TimeoutMonitor'.
[19/Jul/2015:17:41:01] ENGINE Started monitor thread 'Autoreloader'.
[19/Jul/2015:17:41:01] ENGINE Serving on http://127.0.0.1:8080
[19/Jul/2015:17:41:01] ENGINE Bus STARTED
[19/Jul/2015:17:41:05] NATIVE_ADAPTER Traceback (most recent call last):
File "/home/lashni/dev/serve/lib/python3.4/site-packages/cherrypy/_cpnative_server.py", line 27, in respond
sn = cherrypy.tree.script_name(req.uri or "/")
File "/home/lashni/dev/serve/lib/python3.4/site-packages/cherrypy/_cptree.py", line 257, in script_name
path = path[:path.rfind("/")]
TypeError: 'str' does not support the buffer interface
ValueError('invalid literal for int() with base 10: "b\'5"',)
Traceback (most recent call last):
File "/home/lashni/dev/serve/lib/python3.4/site-packages/cherrypy/_cpnative_server.py", line 27, in respond
sn = cherrypy.tree.script_name(req.uri or "/")
File "/home/lashni/dev/serve/lib/python3.4/site-packages/cherrypy/_cptree.py", line 257, in script_name
path = path[:path.rfind("/")]
TypeError: 'str' does not support the buffer interface
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/lashni/dev/serve/lib/python3.4/site-packages/cherrypy/wsgiserver/wsgiserver3.py", line 1068, in communicate
req.respond()
File "/home/lashni/dev/serve/lib/python3.4/site-packages/cherrypy/wsgiserver/wsgiserver3.py", line 856, in respond
self.server.gateway(self).respond()
File "/home/lashni/dev/serve/lib/python3.4/site-packages/cherrypy/_cpnative_server.py", line 88, in respond
self.send_response(s, h, b)
File "/home/lashni/dev/serve/lib/python3.4/site-packages/cherrypy/_cpnative_server.py", line 101, in send_response
req.send_headers()
File "/home/lashni/dev/serve/lib/python3.4/site-packages/cherrypy/wsgiserver/wsgiserver3.py", line 912, in send_headers
status = int(self.status[:3])
ValueError: invalid literal for int() with base 10: "b'5"
Activity
sevmonster commentedon May 27, 2016
This also occurs for me, not tested under other Python versions.
The fact that this has existed since as early as 3.8.0 up to 5.4.0 surprises me.
OS is Win7, Python 3.5.1, CherryPy 5.4.0, not behind any other proxies or load balancers.
Example server setup, based on my own:
Trace:
I followed the docs to the letter, so I'm not entirely sure what the issue is.
Happens for both server instances, as well as when instantiating and accessing just one.
jaraco commentedon Dec 27, 2016
I can confirm this issue persists even after the wsgiserver refactor:
webknjaz commentedon Sep 29, 2017
Hmm.. What about now + cheroot?
Kodiologist commentedon May 23, 2018
Looks like this bug is still there. I just hit it with Python 3.6.5 and CherryPy 15.0.0. Using the documentation's example:
the stack trace I get is:
webknjaz commentedon May 23, 2018
@jaraco turns out, there's incorrect processing of bytes vs str in several places over this module.
It tried to
"b'500 Internal Server Error'"get 3 digits from this thing, which looks like a repr.This originates in this line:
req.uriis of type bytes as well asreq.status, but something went wrong while passing those things back and forth.webknjaz commentedon May 23, 2018
I've started fixing some things, but still need some time/help: #1712
/cc: @jaraco
Initial work to create a test to replicate failure. Ref #1377.
Initial work to create a test to replicate failure. Ref #1377.
Initial work to create a test to replicate failure. Ref #1377.
33 remaining items
Fix native WSGI-less HTTP server support
webknjaz commentedon Jun 22, 2019
Apparently, a similar test already exists: https://github.com/cherrypy/cherrypy/pull/1712/files#diff-38455dfb545934fdb8aaae27bbfd32adR33. And it doesn't fail for a mysterious reason.
cc @jaraco
webknjaz commentedon Jun 22, 2019
I've submitted a fix here: #1785.
It works for me when I use that reproducer. But I want to integrate a proper test before merging.
Fix native WSGI-less HTTP server support
webknjaz commentedon Jun 23, 2019
I've released the fix under v18.1.2 and v17.4.2.
Thanks @Kodiologist for assistance with the reproducer!
MSayfullin commentedon Jul 13, 2019
It looks like this fix breaks server in some circumstances, @webknjaz
After upgrading to the latest v18.1.2 our servers stop responding from time to time and we have such exceptions in log:
Sometimes there will be several of them, sometimes hundreds but at the end application becomes completely unresponsive. No CPU load, no additional memory consumption, nothing new in logs. All requests are just timing out.
Downgrading back to v18.1.1 resolves this issue.
This was happening sporadically but constantly. Most probably because of some specific combination of request data which, unfortunately, we couldn't recognize.
We use Ubuntu 16.04 LTS.
webknjaz commentedon Jul 13, 2019
@MSayfullin looks like that's a Cheroot issue which manifests itself with a combination with a certain version of the OpenSSL. Please create a new issue under Cheroot and fill in all of the required details and include a minimal reproducer if possible.
MSayfullin commentedon Jul 17, 2019
@webknjaz thanks for getting back to me.
Unfortunately, we've already rolled back to a previous version of cherrypy and production environment doesn't fail anymore. We cannot reproduce it in a test environment as well because we didn't catch that specific combination of request params.
What concerns me also is that according to a history of releases in GitHub cheroot's latest one is dated by January 14 and cherrypy version which works for us (v18.1.1) is released on March 27th. This makes me believe that both versions v18.1.1 and v18.1.2 use the same cheroot version and only change that could affect our app is PR #1785
webknjaz commentedon Jul 17, 2019
This doesn't look related to that PR at all. Are you sure you used the same Cheroot version in both cases? Do you pin your env deps versions?
MSayfullin commentedon Jul 18, 2019
We didn't update or downgrade cheroot version and still use 6.2.4. Hope this helps, @webknjaz
webknjaz commentedon Jul 26, 2019
Well, then my best guess is that you were updating something related to openssl on the OS level maybe.
MSayfullin commentedon Jul 26, 2019
That's the thing, only thing updated was cherrypy :)
webknjaz commentedon Jul 26, 2019
Anyway, this needs a real reproducer and a separate issue. The info provided isn't sufficient to conclude any relation to this change.
jaraco commentedon Oct 4, 2019
I don't think we can realistically roll back this change, but do feel free to open a new bug (preferably with a means to reproduce the issue) to track the regression/degradation.