aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar jesopo2019-06-01 22:28:57 +0100
committerGravatar jesopo2019-06-01 22:28:57 +0100
commit20c027fd0bd755ff51ea3a121bcd3b370118e758 (patch)
tree3275441e7180a253253215dc573606c215ac9918
parentadd __str__ and __repr__ defs to IRCLine.ParsedLine (diff)
signature
check if we should enable write throttling before writing, clear _recent_sends
when we turn on throttling and only "turn on" throttling once
-rw-r--r--src/IRCSocket.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/IRCSocket.py b/src/IRCSocket.py
index b93087eb..3a38e8e8 100644
--- a/src/IRCSocket.py
+++ b/src/IRCSocket.py
@@ -124,6 +124,12 @@ class Socket(IRCObject.Object):
def _send(self) -> typing.List[IRCLine.ParsedLine]:
sent_lines = []
+
+ if not self._write_buffer and self._throttle_when_empty:
+ self._throttle_when_empty = False
+ self._write_throttling = True
+ self._recent_sends.clear()
+
throttle_space = self.throttle_space()
if throttle_space:
to_buffer = self._queued_lines[:throttle_space]
@@ -142,9 +148,6 @@ class Socket(IRCObject.Object):
self._write_buffer = self._write_buffer[bytes_written_i:]
- if not self._write_buffer and self._throttle_when_empty:
- self._write_throttling = True
-
self.bytes_written += bytes_written_i
now = time.monotonic()