mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-23 19:19:31 +01:00
IRCNetwork: do not break on socket BlockingIOError
On non-blocking sockets, recv() raises BlockingIOError instead of blocking when there's no data to be read. The correct behaviour is to wait and try again instead of breaking the connection.
This commit is contained in:
parent
e8e26daf05
commit
6a90e99de4
@ -1254,6 +1254,7 @@ utils._proto_utils_class = PyLinkNetworkCoreWithUtils # Used by compatibility w
|
|||||||
|
|
||||||
class IRCNetwork(PyLinkNetworkCoreWithUtils):
|
class IRCNetwork(PyLinkNetworkCoreWithUtils):
|
||||||
S2S_BUFSIZE = 510
|
S2S_BUFSIZE = 510
|
||||||
|
SOCKET_REPOLL_WAIT = 0.5
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
@ -1512,6 +1513,11 @@ class IRCNetwork(PyLinkNetworkCoreWithUtils):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
data = self._socket.recv(2048)
|
data = self._socket.recv(2048)
|
||||||
|
except BlockingIOError:
|
||||||
|
log.debug('(%s) No data to read, trying again later...', self.name)
|
||||||
|
if self._aborted.wait(self.SOCKET_REPOLL_WAIT):
|
||||||
|
break
|
||||||
|
continue
|
||||||
except OSError:
|
except OSError:
|
||||||
# Suppress socket read warnings from lingering recv() calls if
|
# Suppress socket read warnings from lingering recv() calls if
|
||||||
# we've been told to shutdown.
|
# we've been told to shutdown.
|
||||||
|
Loading…
Reference in New Issue
Block a user