_SendWatch
Watches the socket one send waits on (_send_live) and aborts it once
its peer has taken nothing for SEND_STALL_SECONDS.
Attributes
attribute__slots__= ('ws', 'what', 'loop', 'mark', 'since', 'dead', 'handle')attributews= wsattributewhat= whatattributeloop= loopattributemarkOptional[int]= NoneattributesinceOptional[float]= Noneattributedead= Falseattributehandle= loop.call_later(SEND_PROBE_SECONDS, self.probe)Functions
constructor__init__(ws, what, loop) -> NoneSource Code
def __init__(self, ws: Any, what: str, loop: asyncio.AbstractEventLoop) -> None:
self.ws = ws
self.what = what
self.loop = loop
self.mark: Optional[int] = None
self.since: Optional[float] = None
self.dead = False
self.handle = loop.call_later(SEND_PROBE_SECONDS, self.probe)paramwsAnyparamwhatstrparamloopasyncio.AbstractEventLoopReturns
Nonefuncprobe() -> NoneRuns while the send still waits: note progress, or give up on the socket.
Source Code
def probe(self) -> None:
"""Runs while the send still waits: note progress, or give up on the socket."""
mark = _peer_progress(self.ws)
now = self.loop.time()
if self.since is None or (mark is not None and (self.mark is None or mark > self.mark)):
self.mark, self.since = mark, now
elif now - self.since >= SEND_STALL_SECONDS:
self.dead = True
data_logger.warning(f"{self.what} send stalled past {SEND_STALL_SECONDS:.0f}s with "
"nothing taken by the client; dropping it.")
_abort_ws(self.ws)
return
self.handle = self.loop.call_later(SEND_PROBE_SECONDS, self.probe)Returns
None