From f9956cde1eae68c2dcd3c4e72abdba6bdf024d35 Mon Sep 17 00:00:00 2001 From: Nikhil Rao Date: Thu, 15 Jun 2023 23:47:07 -0700 Subject: [PATCH] Fix blocking events (#1198) --- pynecone/app.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pynecone/app.py b/pynecone/app.py index 26b3dcb09..c01ceefa1 100644 --- a/pynecone/app.py +++ b/pynecone/app.py @@ -662,7 +662,9 @@ class EventNamespace(AsyncNamespace): # Process the events. async for update in process(self.app, event, sid, headers, client_ip): # Emit the event. - await self.emit(str(constants.SocketEvent.EVENT), update.json(), to=sid) # type: ignore + await asyncio.create_task( + self.emit(str(constants.SocketEvent.EVENT), update.json(), to=sid) + ) async def on_ping(self, sid): """Event for testing the API endpoint.