close

[Solved] “RuntimeError: generator raised StopIteration” every time I try to run app

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error “RuntimeError: generator raised StopIteration” every time I try to run app in python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How “RuntimeError: generator raised StopIteration” every time I try to run app Error Occurs?

Today I get the following error “RuntimeError: generator raised StopIteration” every time I try to run app in python.

How To Solve “RuntimeError: generator raised StopIteration” every time I try to run app Error ?

  1. How To Solve “RuntimeError: generator raised StopIteration” every time I try to run app Error ?

    To Solve “RuntimeError: generator raised StopIteration” every time I try to run app Error Before this change, a StopIteration raised by, or passing through, a generator simply ended the generator's useful life (the exception was silently swallowed).

  2. “RuntimeError: generator raised StopIteration” every time I try to run app

    To Solve “RuntimeError: generator raised StopIteration” every time I try to run app Error Before this change, a StopIteration raised by, or passing through, a generator simply ended the generator's useful life (the exception was silently swallowed).

Solution 1

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

Solution 2

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.

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read