Skip to content

Commit

Permalink
Small improvements to example apps
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelgrinberg committed Sep 26, 2015
1 parent 86ed25d commit 48d999d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
9 changes: 5 additions & 4 deletions examples/latency.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import engineio

async_mode = 'threading'
# set async_mode to 'threading', 'eventlet' or 'gevent' to force a mode
async_mode = None

eio = engineio.Server(async_mode=async_mode)
app = Flask(__name__)
Expand All @@ -20,15 +21,15 @@ def message(sid, data):


if __name__ == '__main__':
if async_mode == 'threading':
if eio.async_mode == 'threading':
# deploy with Werkzeug
app.run(threaded=True)
elif async_mode == 'eventlet':
elif eio.async_mode == 'eventlet':
# deploy with eventlet
import eventlet
from eventlet import wsgi
wsgi.server(eventlet.listen(('', 5000)), app)
elif async_mode == 'gevent':
elif eio.async_mode == 'gevent':
# deploy with gevent
from gevent import pywsgi
try:
Expand Down
11 changes: 6 additions & 5 deletions examples/simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import engineio

async_mode = 'threading'
# set async_mode to 'threading', 'eventlet' or 'gevent' to force a mode
async_mode = None

eio = engineio.Server(async_mode=async_mode)
app = Flask(__name__)
Expand Down Expand Up @@ -31,15 +32,15 @@ def disconnect(sid):


if __name__ == '__main__':
if async_mode == 'threading':
if eio.async_mode == 'threading':
# deploy with Werkzeug
app.run(threaded=True)
elif async_mode == 'eventlet':
elif eio.async_mode == 'eventlet':
# deploy with eventlet
import eventlet
from eventlet import wsgi
wsgi.server(eventlet.listen(('', 5000)), app)
elif async_mode == 'gevent':
elif eio.async_mode == 'gevent':
# deploy with gevent
from gevent import pywsgi
try:
Expand All @@ -53,4 +54,4 @@ def disconnect(sid):
else:
pywsgi.WSGIServer(('', 5000), app).serve_forever()
else:
print('Unknown async_mode: ' + async_mode)
print('Unknown async_mode: ' + eio.async_mode)

0 comments on commit 48d999d

Please sign in to comment.