Flask sessions cause tabs to freeze #5704
Unanswered
GuyShalomCyberRidge
asked this question in
Q&A
Replies: 2 comments
-
Flask-session locks the sessions file or Redis Key for the duration of the request. This is especially visible when both tabs have the same session.
|
Beta Was this translation helpful? Give feedback.
0 replies
This comment was marked as spam.
This comment was marked as spam.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hey! 🐶
I have a Flask app and I'm running into a weird issue that I think has to do with sessions - but I'm not sure how.
So when connecting to my web app everything works great and requests flow smoothly. However, if I open another tab of the app in the same browser - all requests in both tabs get stuck in a pending state and the app is unusable. The second that I close one of the tabs, requests start flowing again and all the old pending ones fire instantly.
This doesn't occur when opening multiple tabs in different browsers, or when opening another tab in Incognito, only when it's on the same browser.
How I handle sessions
Session are created on user login -
I have a
before_app_request
hook that checks session validity with each request. Every user initiated request also updates last_modified withsession["last_modified"] = datetime.now()
.Other then that some routes use session data like the username in their process.
All session are stored in a Redis instance. However this issue still persists when using another method like Filesystem.
Is my approach to sessions wrong? Is this a known issue with sessions and I should consider another tool?
Any help would be appreciated 🙏
versions
flask 2.2.5
flask-session 0.8.0
redis 7.4.2
Beta Was this translation helpful? Give feedback.
All reactions