Skip to content

Commit

Permalink
Fix more bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
luk3yx committed Aug 22, 2022
1 parent da58f17 commit 4bb7474
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions miniirc.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,18 +288,27 @@ def quote(self, *msg, force=None, tags=None):
self._send_lock.acquire()
sent_bytes = 0
try: # Apparently try/finally is faster than "with".
while sent_bytes < len(msg):
while True:
try:
# Attempt to send to the socket
sent_bytes += self.sock.send(msg[sent_bytes:])
except ssl.SSLWantReadError:
# Wait for the socket to become ready again
readable, _, _ = select.select(
(self.sock,), (), (self.sock,),
self.ping_timeout or self.ping_interval
)
continue
except (BlockingIOError, ssl.SSLWantWriteError):
select.select((), (self.sock,), (self.sock,),
self.ping_timeout or self.ping_interval)
pass
else:
# Break if enough data has been written
if sent_bytes >= len(msg):
break

# Otherwise wait for the socket to become writable
select.select((), (self.sock,), (self.sock,),
self.ping_timeout or self.ping_interval)
except (AttributeError, BrokenPipeError, socket.timeout):
# TODO: Consider not silently ignoring timeouts
if force:
Expand Down

0 comments on commit 4bb7474

Please sign in to comment.