got it so that the master must send an explicit kill for the slaves to shutdown

This commit is contained in:
Stephen McQuay 2011-03-30 22:00:13 -06:00
parent 22153648fa
commit d5f252aff2
2 changed files with 21 additions and 4 deletions

View File

@ -47,6 +47,15 @@ def run_queries(count, order = 3, extra_points = 8, verbose = False):
return (r, submit_end - submit_start, receive_end - receive_start)
def clean_up(inq, expected_participants, shutdown = False):
"""
I replace the normal first argument to the inq with None, and then do some
code branching based on the second paramter, which is shutdown
"""
for i in xrange(expected_participants):
inq.put([None, shutdown, None, None])
if __name__ == '__main__':
parser = OptionParser(usage = "usage: %s [options] <server> <expected participants> <interp count>")
@ -54,6 +63,10 @@ if __name__ == '__main__':
action="store_true", dest="verbose", default=False,
help="verbose flag (display progress bar: %default)")
parser.add_option("-l", "--last-time",
action="store_true", dest="last", default=False,
help="when finished, send shutdown signal to <expected participants> nodes (default: %default)")
parser.add_option('-p', '--port',
type="int", dest="port", default=6666,
help="specify the port to use on the server (default: %default)")
@ -94,8 +107,7 @@ if __name__ == '__main__':
results, submit, receive = run_queries(count, order = options.order, extra_points = options.extra, verbose = options.verbose)
# shut down all participants
for i in xrange(expected_participants):
inq.put([None] * 4)
clean_up(inq, expected_participants)
# post processing
stats = {}
@ -122,3 +134,6 @@ if __name__ == '__main__':
'results' : npresults,
}
s.close()
if options.last:
clean_up(inq, expected_participants, shutdown = True)

View File

@ -22,7 +22,7 @@ def work(inq, outq, g, myname):
while True:
i, o, e, X = inq.get()
if i == None:
break
return o
a = g.run_baker(X, order = o, extra_points = e)
outq.put((i, myname, a['qlin'], a['error'], a['final'], exact(X)))
@ -56,4 +56,6 @@ if __name__ == '__main__':
g.q = np.array([exact(x) for x in g.verts])
myname = options.label
work(inq, outq, g, myname)
shutdown = False
while not shutdown:
shutdown = work(inq, outq, g, myname)