You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
auto_pop of the request context should be executed regardless of whether an exception happened after pushing the context(for example, when opening a session).
The request context is not popped whenever there is a timeout getting the session from Redis.
We can see in following requests the 'g' object still holds information from the failing request.
In ctx.py the context is first pushed and then the session is opened:
_request_ctx_stack.push(self)
# Open the session at the moment that the request context is# available. This allows a custom open_session method to use the# request context (e.g. code that access database information# stored on `g` instead of the appcontext).self.session =self.app.open_session(self.request)
But if open_session() fails, then ctx.auto_pop() is not executed. Perhaps ctx.push() should also be under the try...finally block in app.py?
This is the exception that triggers the context not to be popped:
redis.exceptions:TimeoutError: Timeout reading from socket
Traceback (most recent call last):
File "/var/www/censored_production/env/lib/python2.7/site-packages/newrelic-2.74.0.54/newrelic/api/web_transaction.py", line 738, in __iter__
File "/var/www/censored_production/env/lib/python2.7/site-packages/newrelic-2.74.0.54/newrelic/api/web_transaction.py", line 1114, in __call__
File "/var/www/censored_production/env/lib/python2.7/site-packages/werkzeug/contrib/fixers.py", line 152, in __call__
File "/var/www/censored_production/www/censored/util/logging.py", line 136, in __call__
File "/var/www/censored_production/env/lib/python2.7/site-packages/flask/app.py", line 1813, in wsgi_app
File "/var/www/censored_production/env/lib/python2.7/site-packages/flask/ctx.py", line 321, in push
File "/var/www/censored_production/env/lib/python2.7/site-packages/flask/app.py", line 825, in open_session
File "/var/www/censored_production/env/lib/python2.7/site-packages/flask_session/sessions.py", line 132, in open_session
File "/var/www/censored_production/env/lib/python2.7/site-packages/newrelic-2.74.0.54/newrelic/hooks/datastore_redis.py", line 67, in _nr_wrapper_Redis_method_
File "/var/www/censored_production/env/lib/python2.7/site-packages/redis/client.py", line 880, in get
File "/var/www/censored_production/env/lib/python2.7/site-packages/redis/client.py", line 573, in execute_command
File "/var/www/censored_production/env/lib/python2.7/site-packages/redis/client.py", line 585, in parse_response
File "/var/www/censored_production/env/lib/python2.7/site-packages/redis/connection.py", line 577, in read_response
File "/var/www/censored_production/env/lib/python2.7/site-packages/redis/connection.py", line 238, in read_response
File "/var/www/censored_production/env/lib/python2.7/site-packages/redis/connection.py", line 168, in readline
File "/var/www/censored_production/env/lib/python2.7/site-packages/redis/connection.py", line 139, in _read_from_socket
Environment
Python version: 2.7.6
Flask version: 0.10.1
Werkzeug version: 0.11.11
The text was updated successfully, but these errors were encountered:
Does anybody agree? Notice this specific issue can also be fixed by catching the timeout in flask_session but I still think Flask should handle this gracefully and clean up the context.
Expected Behavior
auto_pop of the request context should be executed regardless of whether an exception happened after pushing the context(for example, when opening a session).
We're using Redis sessions from flask_session:
Actual Behavior
The request context is not popped whenever there is a timeout getting the session from Redis.
We can see in following requests the 'g' object still holds information from the failing request.
In ctx.py the context is first pushed and then the session is opened:
But if open_session() fails, then ctx.auto_pop() is not executed. Perhaps ctx.push() should also be under the try...finally block in app.py?
This is the exception that triggers the context not to be popped:
Environment
The text was updated successfully, but these errors were encountered: