【错误记录/web.py】RuntimeError: generator raised StopIteration(in __iter__ raise StopIteration())

错误详情

  • web.py版本0.40
    Traceback (most recent call last):
      File "/home/pi/.local/lib/python3.7/site-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 "/home/pi/.local/lib/python3.7/site-packages/cheroot/server.py", line 1280, in communicate
        req.respond()
      File "/home/pi/.local/lib/python3.7/site-packages/cheroot/server.py", line 1083, in respond
        self.server.gateway(self).respond()
      File "/home/pi/.local/lib/python3.7/site-packages/cheroot/wsgi.py", line 145, in respond
        for chunk in filter(None, response):
    RuntimeError: generator raised StopIteration
    
  • 说明
    该错误不同于这种

解决方案

  • here
  • 即修改web.py安装目录下的httpserver.py文件
    在这里插入图片描述
    添加最后两行
    def __iter__(self):
        # ...
        try:
            path = self.translate_path(self.path)
            etag = '"%s"' % os.path.getmtime(path)
            client_etag = environ.get("HTTP_IF_NONE_MATCH")
            self.send_header("ETag", etag)
            if etag == client_etag:
                self.send_response(304, "Not Modified")
                self.start_response(self.status, self.headers)
                return
        except OSError:
            pass  # Probably a 404
        except StopIteration: # 添加
            return # 添加
    

你可能感兴趣的:(错误记录)