refactor: move stop logic

This commit is contained in:
Vlad Stan 2023-06-22 14:33:26 +03:00
parent 4238be498f
commit c0632cabe5
2 changed files with 10 additions and 6 deletions

View file

@ -68,7 +68,16 @@ class NostrRouter:
async def stop(self):
for t in self.tasks:
t.cancel()
try:
t.cancel()
except:
pass
for s in self.subscriptions:
try:
nostr.client.relay_manager.close_subscription(s)
except:
pass
self.connected = False
async def _handle_subscriptions(self):

View file

@ -152,11 +152,6 @@ async def ws_relay(websocket: WebSocket) -> None:
while True:
await asyncio.sleep(10)
if not router.connected:
for s in router.subscriptions:
try:
nostr.client.relay_manager.close_subscription(s)
except:
pass
await router.stop()
all_routers.remove(router)
break