made the master's participant count an optional parameter

This commit is contained in:
Stephen McQuay 2011-04-02 01:32:23 -06:00
parent 0f5356867d
commit d61a9dadba

View File

@ -26,6 +26,10 @@ if __name__ == '__main__':
action="store_true", dest="last", default=False, action="store_true", dest="last", default=False,
help="when finished, send shutdown signal to connected nodes (default: %default)") help="when finished, send shutdown signal to connected nodes (default: %default)")
parser.add_option('-n', '--node-count',
type="int", dest="participants", default=None,
help="specify how many participants we should wait for (default: %default)")
parser.add_option('-p', '--port', parser.add_option('-p', '--port',
type="int", dest="port", default=6666, type="int", dest="port", default=6666,
help="specify the port to use on the server (default: %default)") help="specify the port to use on the server (default: %default)")
@ -55,7 +59,8 @@ if __name__ == '__main__':
tasksq, resultsq, masterq, slavesq = get_qs(m) tasksq, resultsq, masterq, slavesq = get_qs(m)
print "wait on all participants" if not options.participants:
print "wait on all announced participants"
participants = 0 participants = 0
while not masterq.empty(): while not masterq.empty():
participants += 1 participants += 1
@ -64,6 +69,12 @@ if __name__ == '__main__':
if participants == 0: if participants == 0:
print "nobody found" print "nobody found"
sys.exit(1) sys.exit(1)
else:
participants = options.participants
print "wait on %d participants" % participants
for i in xrange(participants):
worker = masterq.get()
print "%d of %d: %s is ready" % (i+1, participants, worker)
results = [] results = []