safer disconnect sequence

This commit is contained in:
əlemi 2021-11-19 16:30:08 +01:00
parent 1b72f94043
commit cf35e2cf24

View file

@ -109,8 +109,11 @@ class Dispatcher:
await asyncio.gather(self._writer, self._reader) await asyncio.gather(self._writer, self._reader)
self._logger.debug("Net workers stopped") self._logger.debug("Net workers stopped")
if self._up: if self._up:
if self._up.can_write_eof(): if not self._up.is_closing() and self._up.can_write_eof():
try:
self._up.write_eof() self._up.write_eof()
except OSError as e:
self._logger.error("Could not write EOF : %s", str(e))
self._up.close() self._up.close()
if block: if block:
await self._up.wait_closed() await self._up.wait_closed()