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

flask._request_ctx_stack deprecated #1856

Closed
woutdenolf opened this issue Aug 3, 2022 · 3 comments
Closed

flask._request_ctx_stack deprecated #1856

woutdenolf opened this issue Aug 3, 2022 · 3 comments
Assignees
Labels

Comments

@woutdenolf
Copy link

  /usr/local/lib/python3.7/site-packages/flask_socketio/__init__.py:19: DeprecationWarning: '_request_ctx_stack' is deprecated and will be removed in Flask 2.3.
    from flask import _request_ctx_stack, has_request_context, json as flask_json

From the Flask changelog:

The app and request contexts are managed using Python context
vars directly rather than Werkzeug’s LocalStack. This should result
in better performance and memory use. [#4682](https://github.com/pallets/flask/pull/4682)

    Extension maintainers, be aware that _app_ctx_stack.top and _request_ctx_stack.top
    are deprecated. Store data on g instead using a unique prefix, like g._extension_name_attr.
@miguelgrinberg miguelgrinberg self-assigned this Aug 4, 2022
@mokadevcloud
Copy link

Hi, I have a similar warning after upgrading to Flask 2.2.1. Posting it here as the warning is slightly different:

/home/project/env/lib/python3.8/site-packages/flask_socketio/__init__.py:754: DeprecationWarning: '_request_ctx_stack' is deprecated and will be removed in Flask 2.3. Use 'g' to store data, or 'request_ctx' to access the current context.
  _request_ctx_stack.top.session = session_obj

Thanks

@miguelgrinberg
Copy link
Owner

Please give the main branch a try for a fix. The code adapts to work both in >= 2.2 and < 2.2 releases.

@woutdenolf
Copy link
Author

Seems to work fine. Thanks!

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

No branches or pull requests

3 participants