Skip to content

Commit

Permalink
Merge pull request #250 from Pylons/trigger
Browse files Browse the repository at this point in the history
pull the trigger more often, increases throughput in some testing
  • Loading branch information
digitalresistor authored Apr 11, 2019
2 parents 3030b4a + b76f8e2 commit a19c9e7
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions waitress/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,11 @@ def writable(self):
# if there's data in the out buffer or we've been instructed to close
# the channel (possibly by our server maintenance logic), run
# handle_write
return self.total_outbufs_len or self.will_close
return (
self.total_outbufs_len
or self.will_close
or self.close_when_flushed
)

def handle_write(self):
# Precondition: there's data in the out buffer to be sent, or
Expand Down Expand Up @@ -306,6 +310,7 @@ def write_soon(self, data):
self._flush_outbufs_below_high_watermark()
if not self.connected:
raise ClientDisconnected
num_bytes = len(data)
if data.__class__ is ReadOnlyFileBasedBuffer:
# they used wsgi.file_wrapper
self.outbufs.append(data)
Expand All @@ -320,13 +325,10 @@ def write_soon(self, data):
self.outbufs.append(nextbuf)
self.current_outbuf_count = 0
self.outbufs[-1].append(data)
num_bytes = len(data)
self.current_outbuf_count += num_bytes
self.current_outbuf_count += num_bytes
self.total_outbufs_len += num_bytes
# XXX We might eventually need to pull the trigger here (to
# instruct select to stop blocking), but it slows things down so
# much that I'll hold off for now; "server push" on otherwise
# unbusy systems may suffer.
if self.total_outbufs_len >= self.adj.send_bytes:
self.server.pull_trigger()
return num_bytes
return 0

Expand All @@ -338,6 +340,7 @@ def _flush_outbufs_below_high_watermark(self):
self.connected and
self.total_outbufs_len > self.adj.outbuf_high_watermark
):
self.server.pull_trigger()
self.outbuf_lock.wait()

def service(self):
Expand Down

0 comments on commit a19c9e7

Please sign in to comment.