mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-31 17:31:36 +00:00
parent
56c3c76d8b
commit
7500b1fbee
1 changed files with 8 additions and 1 deletions
|
@ -68,7 +68,7 @@ class NotificationSession(ClientSession):
|
||||||
assert False, request.method
|
assert False, request.method
|
||||||
|
|
||||||
|
|
||||||
|
# FIXME this is often raised inside a TaskGroup, but then it's not silent :(
|
||||||
class GracefulDisconnect(AIOSafeSilentException): pass
|
class GracefulDisconnect(AIOSafeSilentException): pass
|
||||||
|
|
||||||
|
|
||||||
|
@ -238,8 +238,15 @@ class Interface(PrintError):
|
||||||
async with self.group as group:
|
async with self.group as group:
|
||||||
await group.spawn(self.run_fetch_blocks(subscription_res, copy_header_queue))
|
await group.spawn(self.run_fetch_blocks(subscription_res, copy_header_queue))
|
||||||
await group.spawn(self.subscribe_to_headers(header_queue, copy_header_queue))
|
await group.spawn(self.subscribe_to_headers(header_queue, copy_header_queue))
|
||||||
|
await group.spawn(self.monitor_connection())
|
||||||
# NOTE: group.__aexit__ will be called here; this is needed to notice exceptions in the group!
|
# NOTE: group.__aexit__ will be called here; this is needed to notice exceptions in the group!
|
||||||
|
|
||||||
|
async def monitor_connection(self):
|
||||||
|
while True:
|
||||||
|
await asyncio.sleep(1)
|
||||||
|
if not self.session or self.session.is_closing():
|
||||||
|
raise GracefulDisconnect('server closed session')
|
||||||
|
|
||||||
async def subscribe_to_headers(self, header_queue, copy_header_queue):
|
async def subscribe_to_headers(self, header_queue, copy_header_queue):
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Add table
Reference in a new issue