summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Merickel <michael@merickel.org>2019-04-10 03:34:53 -0500
committerMichael Merickel <michael@merickel.org>2019-04-10 21:54:47 -0500
commitb76f8e256fbdfa47d2f0758d597381679ba1eea6 (patch)
treed6e5113aab152f954217b2e51458706e3c35634f
parent5583715063c30fda571ab0e0169b0068403dc53d (diff)
downloadwaitress-trigger.tar.gz
pull the trigger more often, increases throughput in some testingtrigger
-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):