prevent "cannot write() after write_eof()" hopefully
This commit is contained in:
parent
0808bc5b3e
commit
838982c261
1 changed files with 7 additions and 4 deletions
|
@ -228,7 +228,7 @@ class Dispatcher:
|
||||||
|
|
||||||
async def _down_worker(self, timeout:float=30):
|
async def _down_worker(self, timeout:float=30):
|
||||||
while self._dispatching:
|
while self._dispatching:
|
||||||
try: # these 2 will timeout or raise EOFError if client gets disconnected
|
try: # Will timeout or raise EOFError if client gets disconnected
|
||||||
data = await asyncio.wait_for(self._read_packet(), timeout=timeout)
|
data = await asyncio.wait_for(self._read_packet(), timeout=timeout)
|
||||||
|
|
||||||
if self.encryption:
|
if self.encryption:
|
||||||
|
@ -273,12 +273,15 @@ class Dispatcher:
|
||||||
await self.disconnect(block=False)
|
await self.disconnect(block=False)
|
||||||
|
|
||||||
async def _up_worker(self, timeout=1):
|
async def _up_worker(self, timeout=1):
|
||||||
while self._dispatching:
|
while True:
|
||||||
try:
|
try:
|
||||||
packet = await asyncio.wait_for(self._outgoing.get(), timeout=timeout)
|
packet : Packet = await asyncio.wait_for(self._outgoing.get(), timeout=timeout)
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
continue # check again self._dispatching
|
continue # check again self._dispatching
|
||||||
|
|
||||||
|
if not self._dispatching: # uglier than 'while self._dispatching' but I need to check it again after unblocking
|
||||||
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
buffer = packet.serialize()
|
buffer = packet.serialize()
|
||||||
length = len(buffer.getvalue()) # ewww TODO
|
length = len(buffer.getvalue()) # ewww TODO
|
||||||
|
@ -301,7 +304,7 @@ class Dispatcher:
|
||||||
data = self._encryptor.update(data)
|
data = self._encryptor.update(data)
|
||||||
|
|
||||||
self._up.write(data)
|
self._up.write(data)
|
||||||
await self._up.drain()
|
await self._up.drain() # TODO maybe no need to call drain?
|
||||||
|
|
||||||
self.logger.debug("[-->] Sent | %s", repr(packet))
|
self.logger.debug("[-->] Sent | %s", repr(packet))
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|
Loading…
Reference in a new issue