"RuntimeError: generator raised StopIteration" every time I try to run app "RuntimeError: generator raised StopIteration" every time I try to run app python python

"RuntimeError: generator raised StopIteration" every time I try to run app


To judge from the file paths, it looks like you're running Python 3.7. If so, you're getting caught by new-in-3.7 behavior:

PEP 479 is enabled for all code in Python 3.7, meaning that StopIteration exceptions raised directly or indirectly in coroutines and generators are transformed into RuntimeError exceptions. (Contributed by Yury Selivanov in bpo-32670.)

Before this change, a StopIteration raised by, or passing through, a generator simply ended the generator's useful life (the exception was silently swallowed). The module you're using will have to be recoded to work as intended with 3.7.

Chances are they'll need to change:

yield next(seq)

to:

try:    yield next(seq)except StopIteration:    return


So during my recent self-learning on Python, a course required me to install Web.py and I was getting this error and as one of the answer stated, it had to be updated to be compatible with Python 3.7.

I installed the package with pip3 install web.py==0.40-dev1 ran into this error and started searching the web for a solution.

What I did was search through webpy git and find the utils.py file that was more recent in https://github.com/webpy/webpy/tree/master/web, downloaded it, and used it to replace the one that was in my Lib/site-packages/web folder (I'm a Windows user) and it just worked.

Hope this help someone.


My solution was to upgrade these pips

mongoengine from 0.14.0 to 0.19.1 and

flask-mongoengine to 0.9.5

it worked.