Skip to content

Instantly share code, notes, and snippets.

@bulv1ne
Last active August 29, 2015 14:16
Show Gist options
  • Save bulv1ne/1526b759d9cd1d3195e3 to your computer and use it in GitHub Desktop.
Save bulv1ne/1526b759d9cd1d3195e3 to your computer and use it in GitHub Desktop.
Python websocket
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'])
#!/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