Richard Bender
Richard Bender

Reputation: 1134

Communication between Autobahn and Flask/Twisted

I'm building a fairly simple application with Autobahn for WebSocket functionality. It's very similar to a chat server, but one thing I need to do is understand how to accomplish is how to essentially share resources between the WebSocketServerFactory object and my Flask application. The example here:

https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/websocket/echo_wsgi

shows how to combine both Flask and Autobahn, but in my particular use case, I want to be able to dynamically add a chat room when triggered by an authorized call from the Flask component. Is there any sort of best practice on how to go about communicating between the two components in Autobahn?

Upvotes: 1

Views: 1239

Answers (1)

oberstet
oberstet

Reputation: 22051

Flask is based on WSGI, which is a fundamentally blocking API. This doesn't blend well with Twisted or asyncio (the 2 asynchronous network frameworks supported by AutobahnPython).

Here are 2 options:

Upvotes: 4

Related Questions