Attempt to fix handler is closed

Signed-off-by: wulan17 <wulan17@komodos.id>
This commit is contained in:
KurimuzonAkuma 2025-03-01 00:38:17 +03:00 committed by wulan17
parent 921b593285
commit e3a8a781d3
No known key found for this signature in database
GPG key ID: 737814D4B5FF0420

View file

@ -134,12 +134,14 @@ class TCP:
await asyncio.wait_for(self.writer.wait_closed(), TCP.TIMEOUT)
except Exception as e:
log.info("Close exception: %s %s", type(e).__name__, e)
finally:
self.writer = None
async def send(self, data: bytes) -> None:
if self.writer is None:
return None
async with self.lock:
if self.writer is None or self.writer.is_closing():
return None
try:
self.writer.write(data)
await self.writer.drain()