From d61a9dadba0bd771c5c5703af4b48966028c623c Mon Sep 17 00:00:00 2001 From: Stephen Mardson McQuay Date: Sat, 2 Apr 2011 01:32:23 -0600 Subject: [PATCH] made the master's participant count an optional parameter --- bin/master.py | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/bin/master.py b/bin/master.py index dd048a5..af45662 100644 --- a/bin/master.py +++ b/bin/master.py @@ -26,6 +26,10 @@ if __name__ == '__main__': action="store_true", dest="last", default=False, 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', type="int", dest="port", default=6666, help="specify the port to use on the server (default: %default)") @@ -55,15 +59,22 @@ if __name__ == '__main__': tasksq, resultsq, masterq, slavesq = get_qs(m) - print "wait on all participants" - participants = 0 - while not masterq.empty(): - participants += 1 - worker = masterq.get() - print "%d: %s is ready" % (participants, worker) - if participants == 0: - print "nobody found" - sys.exit(1) + if not options.participants: + print "wait on all announced participants" + participants = 0 + while not masterq.empty(): + participants += 1 + worker = masterq.get() + print "%d: %s is ready" % (participants, worker) + if participants == 0: + print "nobody found" + 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 = []