chore: do not try to disconnect ws if not connected

cf https://umap.sentry.io/issues/6331841272/
This commit is contained in:
Yohan Boniface 2025-02-26 09:41:03 +01:00
parent 6e40388f7d
commit dc35039af8

View file

@ -112,11 +112,12 @@ class Peer:
self.client = redis.from_url(settings.REDIS_URL) self.client = redis.from_url(settings.REDIS_URL)
async def disconnect(self): async def disconnect(self):
await self.client.hdel(self.room_key, self.peer_id) if self.is_authenticated:
for pubsub in self._subscriptions: await self.client.hdel(self.room_key, self.peer_id)
await pubsub.unsubscribe() for pubsub in self._subscriptions:
await pubsub.close() await pubsub.unsubscribe()
await self.send_peers_list() await pubsub.close()
await self.send_peers_list()
await self.client.aclose() await self.client.aclose()
async def send_peers_list(self): async def send_peers_list(self):