Skip to content

Commit b1b15e0

Browse files
committed
Safer django socket sending
Sometimes the connection gets closed just before a message is sent This will avoid the ConnectionClosedOK: code = 1001 exception
1 parent d7a05bd commit b1b15e0

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

graphql_ws/django/subscriptions.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
class ChannelsConnectionContext(BaseConnectionContext):
1313
async def send(self, data):
14+
if self.closed:
15+
return
1416
await self.ws.send_json(data)
1517

1618
async def close(self, code):

0 commit comments

Comments
 (0)