summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBert JW Regeer <xistence@0x58.com>2019-04-11 22:10:41 +0100
committerGitHub <noreply@github.com>2019-04-11 22:10:41 +0100
commita19c9e713561181121842712c5bc7172e3e26db0 (patch)
tree7299b69f82946477860f16dbb47e86b454dd97ba
parent3030b4ac084014192be3fb6be43578d9ade855df (diff)
parentb76f8e256fbdfa47d2f0758d597381679ba1eea6 (diff)
downloadwaitress-a19c9e713561181121842712c5bc7172e3e26db0.tar.gz
Merge pull request #250 from Pylons/trigger
pull the trigger more often, increases throughput in some testing
-rw-r--r--waitress/channel.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/waitress/channel.py b/waitress/channel.py
index 12e6fce..26862dc 100644
--- a/waitress/channel.py
+++ b/waitress/channel.py
@@ -88,7 +88,11 @@ class HTTPChannel(wasyncore.dispatcher, object):
# 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
@@ -306,6 +310,7 @@ class HTTPChannel(wasyncore.dispatcher, object):
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)
@@ -320,13 +325,10 @@ class HTTPChannel(wasyncore.dispatcher, object):
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
@@ -338,6 +340,7 @@ class HTTPChannel(wasyncore.dispatcher, object):
self.connected and
self.total_outbufs_len > self.adj.outbuf_high_watermark
):
+ self.server.pull_trigger()
self.outbuf_lock.wait()
def service(self):