check if we should enable write throttling before writing, clear _recent_sends
when we turn on throttling and only "turn on" throttling once
This commit is contained in:
parent
b84d133500
commit
20c027fd0b
1 changed files with 6 additions and 3 deletions
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue