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

uWSGI crashing with KeyError: 'socketio' #20

Closed
stevegaron opened this issue Apr 25, 2014 · 3 comments
Closed

uWSGI crashing with KeyError: 'socketio' #20

stevegaron opened this issue Apr 25, 2014 · 3 comments
Assignees
Labels

Comments

@stevegaron
Copy link

Hey,

I'm having issues making uWSGI working with Flask-SocketIO, it throws a KeyError for socketio in socketio_manage.

These are snippets from my app.py:

from flask import Flask
#other imports here
...
from flask_socketio import SocketIO, emit

app = Flask(__name__)
#blueprints here
...

socketio = SocketIO(app)

@socketio.on('msg')
def msg_on(data):
    emit('response', "bob")

if __name__ == "__main__":
    socketio.run(app, host="0.0.0.0")

I'm running uWSGI like this:

uwsgi --gevent 100 --wsgi-file app.py --callable app 

What am I doing wrong?
I'm running uWSGI 2.0.2, Flask-SocketIO 0.2.2, gevent-socketio 0.3.6

@miguelgrinberg
Copy link
Owner

I'll have to spend some time looking at this myself. My impression based on reading the gevent-socketio is that there isn't official support for uWSGI. The problem that you have is that uWSGI is instantiating a regular gevent server, but gevent-socketio overloads that server and adds its own stuff. For this to work we need to tell uWSGI to create a different server, and I don't really know how to do that, I'll have to play with it and try to figure it out.

@stevegaron
Copy link
Author

Glad to see that I'm not crazy. Let me know if you figure out how to fix this. If you need anything from me, let me know as well. In the meantime I'll have to resort to pulling o_O.

@miguelgrinberg
Copy link
Owner

It does not seem to be possible to run gevent-socketio apps on uWSGI. What's missing is that uWSGI uses its own gevent loop, and there is no easy way to provide an alternative one. A gevent-socketio application requires a specialized server that is based on gevent but does some additional work.

I have added a Deployment section to the documentation that lists the known deployment strategies. I have also added a more friendly error when a incompatible server is used.

Sorry I can't give you better news.

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

2 participants