mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-30 14:49:28 +01:00
Retry when socket.send() fails with BlockingIOError / EAGAIN
This commit is contained in:
parent
2aa00d6efc
commit
d50de12834
21
classes.py
21
classes.py
@ -2091,11 +2091,22 @@ class IRCNetwork(PyLinkNetworkCoreWithUtils):
|
|||||||
|
|
||||||
log.debug("(%s) -> %s", self.name, data)
|
log.debug("(%s) -> %s", self.name, data)
|
||||||
|
|
||||||
try:
|
while True:
|
||||||
self._socket.send(encoded_data)
|
try:
|
||||||
except:
|
self._socket.send(encoded_data)
|
||||||
log.exception("(%s) Failed to send message %r; aborting!", self.name, data)
|
except (BlockingIOError, ssl.SSLWantReadError, ssl.SSLWantWriteError):
|
||||||
self.disconnect()
|
# The send attempt failed, wait a little bit.
|
||||||
|
# I would prefer using a blocking socket and MSG_DONTWAIT in recv()'s flags
|
||||||
|
# but SSLSocket doesn't support that...
|
||||||
|
throttle_time = self.serverdata.get('throttle_time', 0)
|
||||||
|
if self._aborted.wait(throttle_time):
|
||||||
|
break
|
||||||
|
continue
|
||||||
|
except:
|
||||||
|
log.exception("(%s) Failed to send message %r; aborting!", self.name, data)
|
||||||
|
self.disconnect()
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
|
||||||
def send(self, data, queue=True):
|
def send(self, data, queue=True):
|
||||||
"""send() wrapper with optional queueing support."""
|
"""send() wrapper with optional queueing support."""
|
||||||
|
Loading…
Reference in New Issue
Block a user