Created
February 18, 2015 05:38
-
-
Save zbuc/4dd7943b9e663bb5741d to your computer and use it in GitHub Desktop.
Example Multithreaded Flask App
This file contains 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
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