Skip to content

Instantly share code, notes, and snippets.

@abhigenie92
Created April 5, 2016 10:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abhigenie92/6058ac4eaece520ccd92c195b0201689 to your computer and use it in GitHub Desktop.
Save abhigenie92/6058ac4eaece520ccd92c195b0201689 to your computer and use it in GitHub Desktop.
I have a flask server for voip application. I user sends a http request and then I open port for sending data between clients
communicating.
I use twisted to create reactor and transfer the data between clients. The reactor is created in the flask function which responds
to the http reqeust.
@app.route('/start_server',methods=['POST'])
def start_server():
port = reactor.listenTCP(0, Factory())
port.getHost().port
reactor.run()
return jsonify({"port":port})
Now other clients can connect to the server and communicate via the twisted reactor's event loop shown below.
Question: After the function start_server() returns and will the reactor started in it will alive like thread?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment