From 64498ba3f26b9ad85c78dd1e29c45460d64073dd Mon Sep 17 00:00:00 2001 From: Luna Date: Fri, 26 Jun 2020 22:21:26 -0300 Subject: [PATCH] only dispatch to states with websockets --- litecord/pubsub/utils.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/litecord/pubsub/utils.py b/litecord/pubsub/utils.py index 636ba36..1d6bca6 100644 --- a/litecord/pubsub/utils.py +++ b/litecord/pubsub/utils.py @@ -30,11 +30,12 @@ async def send_event_to_states( """Dispatch an event to a list of states.""" res = [] + event, data = event_data for state in states: try: - event, data = event_data - await state.ws.dispatch(event, data) - res.append(state.session_id) + if state.ws: + await state.ws.dispatch(event, data) + res.append(state.session_id) except Exception: log.exception("error while dispatching")