Forums

Dictionary randomly deleting & adding keys

Dear Community, before I'll get to the problem: I am no experienced web-programmer and am doing this totally as a hobby, I hope this explains my (maybe) quite naive question.

The job of my website is to serve as a quasi database for a telegram-bot. The only thing I'm trying to store are key-value pairs (which I'm doing as a python dictionary). The website is served as a flask server.

Now to the problem: There are some keys that when I invoke the delete method with that key in the request, that are at first deleted but magically come back later. Or not.

I can make subsequent requests that retrieve the dictionary to the server and sometimes the key comes back and sometimes it's deleted (as intended). The data is just stored as a python dictionary - I don't understand what triggers this? I never had any problems with dictionaries before.

Maybe they're are not safe to use on a server? I have no idea.

Thank you in advance.

Each of your web workers is running in a separate process and does not share data. Consider a database to share data between processes.