RuntimeError('generator raised StopIteration')
web.py version: 0.40
cheroot version: 8.2.1
Python version: 3.7.3 (Debian buster)
To reiterate, thanks again for porting web.py to Python 3. This has been very helpful.
When serving static assets, and the server wants to respond with 304 Not Modified, web.py raises StopIteration. Now, in most cases, StopIteration is used as an internal exception to tell the web.py to prevent execution of the request handling. In this particular case, it is bubbling up to Cheroot. Here is the stack frame:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/web/httpserver.py", line 239, in __iter__
raise StopIteration()
StopIteration
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/cheroot/server.py", line 1280, in communicate
req.respond()
File "/usr/local/lib/python3.7/dist-packages/cheroot/server.py", line 1083, in respond
self.server.gateway(self).respond()
File "/usr/local/lib/python3.7/dist-packages/cheroot/wsgi.py", line 145, in respond
for chunk in filter(None, response):
RuntimeError: generator raised StopIteration
RuntimeError('generator raised StopIteration')
RuntimeError('generator raised StopIteration')
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/web/httpserver.py", line 239, in __iter__
raise StopIteration()
StopIteration
Here is where it is raised in web.py:
https://github.com/webpy/webpy/blob/master/web/httpserver.py#L239
Here is where it is received by cheroot:
Since the function in web.py is a generator, replacing raise StopIteration() with a return would fix this problem. Would you accept a pull request changing this line? All other raise StopIteration() uses in web.py look valid.