3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-01 01:09:22 +01:00

IRCNetwork: try to abort immediately if the send queue is full

This commit is contained in:
James Lu 2018-10-08 16:25:53 -07:00
parent 0b3793380b
commit 60b7894cd6

View File

@ -14,6 +14,7 @@ import ssl
import hashlib import hashlib
import ipaddress import ipaddress
import queue import queue
QUEUE_FULL = queue.Full
import functools import functools
import string import string
import re import re
@ -1921,7 +1922,12 @@ class IRCNetwork(PyLinkNetworkCoreWithUtils):
if queue: if queue:
# XXX: we don't really know how to handle blocking queues yet, so # XXX: we don't really know how to handle blocking queues yet, so
# it's better to not expose that yet. # it's better to not expose that yet.
try:
self._queue.put_nowait(data) self._queue.put_nowait(data)
except QUEUE_FULL:
log.error('(%s) Max SENDQ exceeded (%s), disconnecting!', self.name, self._queue.maxsize)
self.disconnect()
raise
else: else:
self._send(data) self._send(data)