Replies: 2 comments 1 reply
-
On first glance this seems perfectly reasonable - and yes please go ahead and put up a PR! |
Beta Was this translation helpful? Give feedback.
1 reply
-
Available now in 4.10.0 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi @alisaifee!
Currently we use one
PubSub
object per user connection, and then uselisten()
to handle incoming responses on just that one subscribed channel. We'd like to move to having one PubSub peruvicorn
worker instead. To do that, however, we need to have the registered handlers be async, since they need to do work like write back to the client websockets.A proposal would be:
self.patterns
orself.handlers
map, check if they are coroutines or sync functions; if sync, just call regularly, otherwiseawait
them. (can be something like Starlette's is_async_callable )What do you think? Only downside would be a slightly more expensive call to
handle_message
since making it async has a small amount of overhead. Happy to take this on if it sounds good to you.Beta Was this translation helpful? Give feedback.
All reactions