This commit is contained in:
Flowseal committed 2026-11-01 10:08:01 +03:00
1 parent 50d539c718
commit 1636903c8f
6 files changed
+319 -29

No files matched your search

+14 -13
View File
@@ -225,20 +225,21 @@ class RawWebSocket:
return None
async def close(self):
if self._closed:
return
self._closed = True
try:
self.writer.write(
self._build_frame(self.OP_CLOSE, b'', mask=True))
await self.writer.drain()
except Exception:
pass
try:
self.writer.close()
await self.writer.wait_closed()
except Exception:
pass
if not self._closed:
self._closed = True
try:
self.writer.write(
self._build_frame(self.OP_CLOSE, b'', mask=True))
await self.writer.drain()
except Exception:
pass
finally:
try:
self.writer.close()
await self.writer.wait_closed()
except Exception:
pass
_WS_CLOSE_REASONS = {
1000: 'normal', 1001: 'going_away', 1002: 'protocol_error',