Skip to content

Instantly share code, notes, and snippets.

@zbuc
Created February 18, 2015 05:38
Show Gist options
  • Save zbuc/4dd7943b9e663bb5741d to your computer and use it in GitHub Desktop.
Save zbuc/4dd7943b9e663bb5741d to your computer and use it in GitHub Desktop.
Example Multithreaded Flask App
from flask import Flask
app = Flask("proxapp")
@app.route('/')
def hello_world():
return 'Hello World!'
# since we're using threads, shouldn't we be able to pause execution of one?
@app.route('/slow')
def slow():
import time
time.sleep(10)
return 'zzz'
with open('./log', 'a+') as log:
try:
app.run(threaded=True)
log.write("done adding wsgi app\n")
except Exception, e:
log.write(repr(e))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment