INNER CODE UNIT · Python

__aexit__

permitio/fastapi_websocket_pubsub · fastapi_websocket_pubsub/event_broadcaster.py:86

    async def __aexit__(self, exc_type, exc, tb):
        async with self._event_broadcaster._context_manager_lock:
            try:
                if self._listen:
                    self._event_broadcaster._listen_count -= 1
                    # if this was last listener - we can stop the reading task
                    if self._event_broadcaster._listen_count == 0:
                        # Cancel task reading broadcast subscriptions
                        if self._event_broadcaster._subscription_task is not None:
                            logger.info("Cancelling broadcast listen task")
                            self._event_broadcaster._subscription_task.cancel()
                            self._event_broadcaster._subscription_task = None

                if self._share:
                    self._event_broadcaster._share_count -= 1
                    # if this was last sharer - we can stop subscribing to internal events - we aren't sharing anymore
                    if self._event_broadcaster._share_count == 0:
                        # Unsubscribe from internal events

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…