DB making running forever

Question:
By importing the replit database in python, the code will never stop running.
Repl link/Link to where the bug appears:
Just get a python repl and import db and then do something with the database
Screenshots, links, or other helpful context:

from replit import db

db["hello"]="hello"
print(db["hello"])
quit()

If you do something with the database (e.g. set a key) the code keep running forever, no matter what happens.


As you can see in the image, after printing ‘Hello’, it just keeps running, forever.

The issue here is not actually using the DB, but rather that you are using quit(). It usually has a lot of issues with Replit. So simply remove the quit() line and it should work fine.

1 Like

even if I remove the quit() thing it still runs forever somehow…

1 Like

Could you try running kill 1 in the Shell? Otherwise, please send the link to your Repl.

1 Like

I meant that the code doesn’t terminate itself, so if I press the stop button, it stops, but the code never stops by itself

Yes, did the command fix that?

1 Like

nope, it still runs forever :frowning:

Can you please send the link to your Repl, then?

2 Likes

https://replit.com/@Ivanzong/database#main.py

1 Like

Hmm, not sure. I’ll look into this later.

2 Likes

I believe this issue as been here for a long time, but no one reported it

1 Like

Hmm, unable to reproduce using a fork.

But an important thing to note is that the Packager output reveals there is a package conflict between flask (which comes pre-installed at ^3.0.0) and replit. This means that it didn’t actually install the replit package correctly, or that there may be errors from replit’s dependencies.
Looking at the repl and reproducing, it seems that replit package is indeed installed, but the package manager poetry doesn’t realize.

Since the flask version is incompatible with the replit version (as replit depends on a lower version of flask), the replit database will not work. (It just happens that replit has been installed, when it shouldn’t, so you don’t get a ModuleNotFoundError.)

There are many topics about the replit - flask incompatibility, you could search for it on this forum.

3 Likes

well I got the code to end but it’s not exactly what you were looking for because I removed virtually everything including the database import meaning it is pretty much a basic print command

2 Likes

How does that help the OP exactly?

1 Like

well, it does what he wanted it to do right?

1 Like

Not really? It’s supposed to be using the DB, and shouldn’t be getting stuck because of it.

1 Like

Oh I see I’ll continue working on finding the error then

1 Like

Here’s my screen recording:


as you can see in the recording, it runs forever:

Hopefully it helps finding what the problem is :slight_smile:

2 Likes

That’s strange. Does it run forever if you do python main.py in the Shell?
Refer to my previous post for the most probable reason why this is happening (package conflicts). If you fix the package conflicts, the problem will probably not occur.

You could also try exiting forcefully at the end, with an exception or sys.exit().

2 Likes

it also runs forever in python main.py