refactor: move stop logic
This commit is contained in:
parent
4238be498f
commit
c0632cabe5
2 changed files with 10 additions and 6 deletions
|
|
@ -68,7 +68,16 @@ class NostrRouter:
|
|||
|
||||
async def stop(self):
|
||||
for t in self.tasks:
|
||||
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):
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue