reset ping_sent in wait_for too
This commit is contained in:
parent
b4eaf6c24c
commit
6fddfb7fe9
1 changed files with 6 additions and 6 deletions
|
@ -67,6 +67,7 @@ class Server(IServer):
|
||||||
self._read_queue: Deque[Line] = deque()
|
self._read_queue: Deque[Line] = deque()
|
||||||
self._process_queue: Deque[Line] = deque()
|
self._process_queue: Deque[Line] = deque()
|
||||||
|
|
||||||
|
self._ping_sent = False
|
||||||
self._read_lguard = RLock()
|
self._read_lguard = RLock()
|
||||||
self.read_lock = self._read_lguard
|
self.read_lock = self._read_lguard
|
||||||
self._read_lwork = asyncio.Lock()
|
self._read_lwork = asyncio.Lock()
|
||||||
|
@ -281,7 +282,6 @@ class Server(IServer):
|
||||||
self._read_queue.append(line)
|
self._read_queue.append(line)
|
||||||
|
|
||||||
async def _read_lines(self):
|
async def _read_lines(self):
|
||||||
ping_sent = False
|
|
||||||
while True:
|
while True:
|
||||||
async with self._read_lguard:
|
async with self._read_lguard:
|
||||||
pass
|
pass
|
||||||
|
@ -297,13 +297,12 @@ class Server(IServer):
|
||||||
|
|
||||||
for done in dones:
|
for done in dones:
|
||||||
if isinstance(done.result(), Line):
|
if isinstance(done.result(), Line):
|
||||||
ping_sent = False
|
self._ping_sent = False
|
||||||
line = done.result()
|
self._process_queue.append(done.result())
|
||||||
self._process_queue.append(line)
|
|
||||||
elif done.result() is None:
|
elif done.result() is None:
|
||||||
if not ping_sent:
|
if not self._ping_sent:
|
||||||
await self.send(build("PING", ["hello"]))
|
await self.send(build("PING", ["hello"]))
|
||||||
ping_sent = True
|
self._ping_sent = True
|
||||||
else:
|
else:
|
||||||
await self.disconnect()
|
await self.disconnect()
|
||||||
raise ServerDisconnectedException()
|
raise ServerDisconnectedException()
|
||||||
|
@ -334,6 +333,7 @@ class Server(IServer):
|
||||||
while True:
|
while True:
|
||||||
line = await self._read_line(timeout)
|
line = await self._read_line(timeout)
|
||||||
if line:
|
if line:
|
||||||
|
self._ping_sent = False
|
||||||
self._process_queue.append(line)
|
self._process_queue.append(line)
|
||||||
if response_obj.match(self, line):
|
if response_obj.match(self, line):
|
||||||
return line
|
return line
|
||||||
|
|
Loading…
Add table
Reference in a new issue