Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

queues are empty after code change #2

Open
anoteboom opened this issue Aug 13, 2020 · 5 comments
Open

queues are empty after code change #2

anoteboom opened this issue Aug 13, 2020 · 5 comments

Comments

@anoteboom
Copy link

When I'm debugging code, as soon as i change something, flask does a reload., and all queues are empty again.

I think I'm going back to the separate process for a task emulator. Or do you have an idea of how to keep the queues?

@JoshuaFox
Copy link
Collaborator

Thank you for the report. Now investigating.

@JoshuaFox
Copy link
Collaborator

What do you think of an implementation that stores emulator state in pickle files? The memory-based implementation would still be availble.

Advantages

  • State stored across code-reload and across process restart
  • Makes the implementation more complex than the 70-line single file.

Disadvantages

  • You might not want state stored across process restarts in a debugging scenario (but you can delete the files)
  • Pickles are not a robust datastore (but our goal here is simplicity)

@anoteboom
Copy link
Author

The best situation would be to replicate behaviour of the old python2 dev_appserver. So when you explicitly would restart your flask_server, it is not a problem that it forgets all tasks.
And when the flask server detects a code changes and reloads, it should retain them.

I'm curious how the dev_appserver did that.
I would try to stay away from writing it in tempfiles, Keeping the code simple is important.

@JoshuaFox
Copy link
Collaborator

Flask uses Werkzeug which does not reload code. It completely restarts the process when it detects a code change. (Source code).

I could save queue state at exit, and reload on initialization. This would mean a temp file, but only used for "hibernating" , not as the regular place to hold state. This solution would mean that state is also preserved across intentional restarts. Does that make sense?

@JoshuaFox
Copy link
Collaborator

@anoteboom I implemented the "hibernate" approach. It can be turned off with hibernation=False in the constructor. Please let me know what you think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants