reduce cognitive complexity

This commit is contained in:
Stefan Allius
2024-10-06 21:20:53 +02:00
parent d7628689f0
commit 595b68ba03

View File

@@ -179,11 +179,7 @@ class AsyncStream(AsyncIfcImpl):
self.proc_start = time.time()
while True:
try:
if self.proc_start:
proc = time.time() - self.proc_start
if proc > self.proc_max:
self.proc_max = proc
self.proc_start = None
self.__calc_proc_time()
dead_conn_to = self.__timeout()
await asyncio.wait_for(self.__async_read(),
dead_conn_to)
@@ -220,6 +216,13 @@ class AsyncStream(AsyncIfcImpl):
f"{traceback.format_exc()}")
await asyncio.sleep(0) # be cooperative to other task
def __calc_proc_time(self):
if self.proc_start:
proc = time.time() - self.proc_start
if proc > self.proc_max:
self.proc_max = proc
self.proc_start = None
async def disc(self) -> None:
"""Async disc handler for graceful disconnect"""
self.remote = None