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

generate a request context for all the WS handler exec environments #77

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

trbabb
Copy link

@trbabb trbabb commented Sep 25, 2019

Inside of websocket handlers, the flask request context doesn't currently exist. This makes it difficult to do things like access cookies, and also breaks compatibility with other flask plugins (like flask-login, in my case, which pre-loads user information, and assumes the request context is valid).

In my own app, this seems to work. Looks like activity on this repo is low, but I thought I'd offer the PR in case it might be useful to other users of this repo & it makes sense to install unconditionally.

@rosensama
Copy link
Contributor

Thanks for sharing this. This is something I've been looking for since the advice in the README to pass ws.environ to app.request_context() is wrong (out of date?).

However, when I try the MR for gevent, I get the following. I'm guessing something has had a breaking change since you authored the MR. Any suggestions?

Traceback (most recent call last):
  File "src/gevent/greenlet.py", line 854, in gevent._gevent_cgreenlet.Greenlet.run
  File "/home/rosensama/.local/share/virtualenvs/mendoza-HQwqgdmM/lib/python3.9/site-packages/flask_uwsgi_websocket/_gevent.py", line 80, in wrapped_handler
    return handler(client, **args)
TypeError: 'gevent._gevent_cgreenlet.Greenlet' object is not callable
2020-12-28T22:12:14Z <Greenlet at 0x7fd9ddec6bf0: wrapped_handler> failed with TypeError

Flask 1.1.2
Flask-uWSGI-WebSocket 0.6.1
uWSGI 2.0.19.1
gevent 20.9.0

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

Successfully merging this pull request may close these issues.

2 participants