Closed sergpsu closed 2 months ago
Hi guys. Need a proper way to make some cleanups after client disconnects. What I've implemented looks like this:
class MyEventSourceResponse(EventSourceResponse): user_id: uuid.UUID def __init__(self, user_id: uuid.UUID, *args, **kwargs): self.user_id = user_id super().__init__(*args, **kwargs) # @staticmethod async def listen_for_disconnect(self, receive: Receive) -> None: while True: message = await receive() if message["type"] == "http.disconnect": #------------------------ DOING CLEANUP BASED ON self.user_id ------------------------- break
So listen_for_disconnect cannot be staticmethod and this is not a clean way to subclass. Is there a better way?
Closed due to inactivity.
Hi guys. Need a proper way to make some cleanups after client disconnects. What I've implemented looks like this:
So listen_for_disconnect cannot be staticmethod and this is not a clean way to subclass. Is there a better way?