Last active
August 29, 2015 14:16
-
-
Save bulv1ne/1526b759d9cd1d3195e3 to your computer and use it in GitHub Desktop.
Python websocket
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import redis | |
import uwsgi | |
def application(env, start_response): | |
uwsgi.websocket_handshake(env['HTTP_SEC_WEBSOCKET_KEY'], env.get('HTTP_ORIGIN', '')) | |
r = redis.Redis() | |
p = r.pubsub(ignore_subscribe_messages=True) | |
p.subscribe('test') | |
for message in p.listen(): | |
uwsgi.websocket_send(message['data']) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
uwsgi --http :8080 --http-websockets --threads 100 --wsgi-file app.py |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment