arroba icon indicating copy to clipboard operation
arroba copied to clipboard

Add asyncio support

Open snarfed opened this issue 2 years ago • 0 comments

This would mainly just be in docs and the demo PDS, hopefully I shouldn't have to change much or any of the subscription XRPC handler code (eg xrpc_sync.subscribe_repos) itself. The current design is that subscription handlers are just generators, which I think I can wrap in an asyncio coroutine to be served in eg an ASGI framework and server.

Sadly flask-sock doesn't support asyncio though, https://github.com/miguelgrinberg/flask-sock/issues/47. Flask-SocketIO supposedly does, https://github.com/miguelgrinberg/Flask-SocketIO/issues/1193 , but I can't tell if it's real, ie it pauses the coroutine while it's waiting to receive data from (or send to) the client, or if it's just compatible and can be run in an asyncio event loop but still blocks an entire thread. I need to learn more, or maybe try it and see.

snarfed avatar Sep 02 '23 15:09 snarfed