Checking if we should enable write buffer should be in _fill_throttle()

This commit is contained in:
jesopo 2019-06-07 08:02:04 +01:00
parent 23d2993b9f
commit 1f1b63ea6d

View file

@ -129,8 +129,12 @@ class Socket(IRCObject.Object):
else:
self._queued_lines.append(line)
def _fill_throttle(self):
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]
@ -139,11 +143,6 @@ class Socket(IRCObject.Object):
self._immediate_buffer(line)
def _send(self) -> typing.List[IRCLine.SentLine]:
if not self._write_buffer and self._throttle_when_empty:
self._throttle_when_empty = False
self._write_throttling = True
self._recent_sends.clear()
bytes_written_i = self._socket.send(self._write_buffer)
bytes_written = self._write_buffer[:bytes_written_i]