reduce cognitive complexity
This commit is contained in:
@@ -179,11 +179,7 @@ class AsyncStream(AsyncIfcImpl):
|
|||||||
self.proc_start = time.time()
|
self.proc_start = time.time()
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
if self.proc_start:
|
self.__calc_proc_time()
|
||||||
proc = time.time() - self.proc_start
|
|
||||||
if proc > self.proc_max:
|
|
||||||
self.proc_max = proc
|
|
||||||
self.proc_start = None
|
|
||||||
dead_conn_to = self.__timeout()
|
dead_conn_to = self.__timeout()
|
||||||
await asyncio.wait_for(self.__async_read(),
|
await asyncio.wait_for(self.__async_read(),
|
||||||
dead_conn_to)
|
dead_conn_to)
|
||||||
@@ -220,6 +216,13 @@ class AsyncStream(AsyncIfcImpl):
|
|||||||
f"{traceback.format_exc()}")
|
f"{traceback.format_exc()}")
|
||||||
await asyncio.sleep(0) # be cooperative to other task
|
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 def disc(self) -> None:
|
||||||
"""Async disc handler for graceful disconnect"""
|
"""Async disc handler for graceful disconnect"""
|
||||||
self.remote = None
|
self.remote = None
|
||||||
|
|||||||
Reference in New Issue
Block a user