From 3202e4e63b5a32e943c36de7f627443a25d1780e Mon Sep 17 00:00:00 2001 From: Zev Benjamin Date: Tue, 23 Jul 2013 16:11:57 -0400 Subject: [PATCH 1/3] deferring_http_channel: make delay and writable_check instance variables Having them as class variables didn't have any observable issues, but it couldn't possibly have been correct. --- supervisor/http.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/supervisor/http.py b/supervisor/http.py index 8f12f25ee..30b01065c 100644 --- a/supervisor/http.py +++ b/supervisor/http.py @@ -345,8 +345,10 @@ class deferring_http_channel(http_server.http_channel): # order to spew tail -f output faster (speculative) ac_out_buffer_size = 4096 - delay = False - writable_check = time.time() + def __init__(self, *args, **kwargs): + self.delay = False + self.writable_check = time.time() + http_server.http_channel.__init__(self, *args, **kwargs) def writable(self, t=time.time): now = t() From d68b8baaf6a352b2e7cff7a1eb6188ba197f55a5 Mon Sep 17 00:00:00 2001 From: Zev Benjamin Date: Tue, 23 Jul 2013 16:18:11 -0400 Subject: [PATCH 2/3] deferring_http_channel: fix delay logic The previous code was checking whether it had been self.delay seconds since the last check, not whether it had been self.delay seconds since we started delaying. --- supervisor/http.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/supervisor/http.py b/supervisor/http.py index 30b01065c..193144f73 100644 --- a/supervisor/http.py +++ b/supervisor/http.py @@ -346,18 +346,14 @@ class deferring_http_channel(http_server.http_channel): ac_out_buffer_size = 4096 def __init__(self, *args, **kwargs): - self.delay = False - self.writable_check = time.time() + self.delay_until = False http_server.http_channel.__init__(self, *args, **kwargs) - def writable(self, t=time.time): - now = t() - if self.delay: + def writable(self): + if self.delay_until: # we called a deferred producer via this channel (see refill_buffer) - last_writable_check = self.writable_check - self.writable_check = now - elapsed = now - last_writable_check - if elapsed > self.delay: + if time.time() > self.delay_until: + self.delay_until = False return True else: return False @@ -384,12 +380,12 @@ def refill_buffer (self): data = p.more() if data is NOT_DONE_YET: - self.delay = p.delay + self.delay_until = time.time() + p.delay return elif data: self.ac_out_buffer = self.ac_out_buffer + data - self.delay = False + self.delay_until = False return else: self.producer_fifo.pop() From d7b0f650adb1ee5b5a5ad8b3c29489a8d1cc62ec Mon Sep 17 00:00:00 2001 From: Zev Benjamin Date: Mon, 15 Jul 2013 13:40:08 -0400 Subject: [PATCH 3/3] Lower select timeout The various deferring classes in http.py would try to delay by 0.1 seconds when data was not yet ready. However, since the select timeout was 1 second, we'd end up delaying that long, instead. This amounted to each start or stop command taking 1 second to complete. The comment about the minimum timeout appears to have never been true. --- supervisor/supervisord.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/supervisor/supervisord.py b/supervisor/supervisord.py index 85b82d16f..91a2bd737 100755 --- a/supervisor/supervisord.py +++ b/supervisor/supervisord.py @@ -179,7 +179,7 @@ def ordered_stop_groups_phase_2(self): def runforever(self): events.notify(events.SupervisorRunningEvent()) - timeout = 1 # this cannot be fewer than the smallest TickEvent (5) + timeout = 0.1 socket_map = self.options.get_socket_map()