A few tweaks to the status page so that we can continue to see child status while the child is finishing up its requests.

This commit is contained in:
Ryan Williams 2010-10-01 15:20:11 -07:00 committed by R. Tyler Croy
parent 4d04e6578e
commit b8cae31100
2 changed files with 10 additions and 11 deletions

View File

@ -165,6 +165,7 @@ def get_statusobj():
def read_pipe_and_die(the_pipe, server_coro):
dying = False
try:
while True:
eventlet.hubs.trampoline(the_pipe, read=True)
@ -172,16 +173,15 @@ def read_pipe_and_die(the_pipe, server_coro):
# this is how the controller tells the child to send a status update
if c == 's' and get_statusobj():
get_statusobj().send_status_to_controller()
continue
else:
break
elif not dying:
dying = True # only send ExitChild once
eventlet.greenthread.kill(server_coro, ExitChild)
# continue to listen for status pings while dying
except socket.error:
pass
try:
os.close(the_pipe)
except socket.error:
pass
return server_coro.throw(ExitChild)
# if here, perhaps the controller's process went down; we should die too
if not dying:
eventlet.greenthread.kill(server_coro, ExitChild)
def deadman_timeout(signum, frame):
@ -267,7 +267,6 @@ def serve_from_child(sock, config, controller_pid):
server = server_event.wait()
last_outstanding = None
## Let's tell our parent that we're dying
try:
os.kill(controller_pid, signal.SIGUSR1)
@ -275,6 +274,7 @@ def serve_from_child(sock, config, controller_pid):
if not e.errno == errno.ESRCH:
raise
last_outstanding = None
while server.outstanding_requests:
if last_outstanding != server.outstanding_requests:
print "(%s) %s requests remaining, waiting... (timeout after %s)" % (

View File

@ -61,12 +61,11 @@ class Server(object):
def collect_child_status(self, child):
self.child_events[child.pid] = event.Event()
# note: this may block the controller a little bit, we don't care
# so much because it's not doing any real work
try:
try:
# tell the child to POST its status to us, we handle it in the
# wsgi application below
eventlet.hubs.trampoline(child.kill_pipe, write=True)
os.write(child.kill_pipe, 's')
t = eventlet.Timeout(1)
results = self.child_events[child.pid].wait()