|
|
|
@ -820,20 +820,20 @@ class Network(Logger, NetworkRetryManager[ServerAddr]): |
|
|
|
assert iface.ready.done(), "interface not ready yet" |
|
|
|
assert iface.ready.done(), "interface not ready yet" |
|
|
|
# try actual request |
|
|
|
# try actual request |
|
|
|
success_fut = asyncio.ensure_future(func(self, *args, **kwargs)) |
|
|
|
success_fut = asyncio.ensure_future(func(self, *args, **kwargs)) |
|
|
|
await asyncio.wait([success_fut, iface.got_disconnected], return_when=asyncio.FIRST_COMPLETED) |
|
|
|
await asyncio.wait([success_fut, iface.got_disconnected.wait()], return_when=asyncio.FIRST_COMPLETED) |
|
|
|
if success_fut.done() and not success_fut.cancelled(): |
|
|
|
if success_fut.done() and not success_fut.cancelled(): |
|
|
|
if success_fut.exception(): |
|
|
|
if success_fut.exception(): |
|
|
|
try: |
|
|
|
try: |
|
|
|
raise success_fut.exception() |
|
|
|
raise success_fut.exception() |
|
|
|
except RequestTimedOut: |
|
|
|
except RequestTimedOut: |
|
|
|
await iface.close() |
|
|
|
await iface.close() |
|
|
|
await iface.got_disconnected |
|
|
|
await iface.got_disconnected.wait() |
|
|
|
continue # try again |
|
|
|
continue # try again |
|
|
|
except RequestCorrupted as e: |
|
|
|
except RequestCorrupted as e: |
|
|
|
# TODO ban server? |
|
|
|
# TODO ban server? |
|
|
|
iface.logger.exception(f"RequestCorrupted: {e}") |
|
|
|
iface.logger.exception(f"RequestCorrupted: {e}") |
|
|
|
await iface.close() |
|
|
|
await iface.close() |
|
|
|
await iface.got_disconnected |
|
|
|
await iface.got_disconnected.wait() |
|
|
|
continue # try again |
|
|
|
continue # try again |
|
|
|
return success_fut.result() |
|
|
|
return success_fut.result() |
|
|
|
# otherwise; try again |
|
|
|
# otherwise; try again |
|
|
|
|