Skip to content

Instantly share code, notes, and snippets.

@miku
Last active March 11, 2019 18:10
Show Gist options
  • Select an option

  • Save miku/4465839 to your computer and use it in GitHub Desktop.

Select an option

Save miku/4465839 to your computer and use it in GitHub Desktop.
Minimal flask + eventlet example.
#!/usr/bin/env python
# http://stackoverflow.com/questions/14180179/eventlet-spawn-doesnt-work-as-expected/14180227#14180227
from flask import Flask
import eventlet
eventlet.monkey_patch()
app = Flask(__name__)
app.debug = True
def background():
print('This happens in the background')
@app.route('/')
def index():
eventlet.spawn(background)
return "Hello World"
if __name__ == '__main__':
app.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment