From c9ac24f37d75d103df68fefde3d5cfe88d0ea939 Mon Sep 17 00:00:00 2001 From: Stefan Huber Date: Wed, 8 May 2013 09:35:08 +0200 Subject: [PATCH] Add option -n --- paralleljobs.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/paralleljobs.py b/paralleljobs.py index f2e6eea..baf7965 100755 --- a/paralleljobs.py +++ b/paralleljobs.py @@ -166,6 +166,7 @@ COMMANDS: OPTIONS: -d database the database to process + -n num in -w mode, only perform num-many jobs -p cols-def create properties table with SQL column spec -v print output of the job's command @@ -206,9 +207,10 @@ if __name__ == "__main__": propdef = None work = False status = False + numjobs = None try: - opts, args = getopt.getopt(sys.argv[1:], "hd:c:p:wsv") + opts, args = getopt.getopt(sys.argv[1:], "hd:c:p:wsvn:") for opt, arg in opts: if opt == "-h": @@ -226,6 +228,8 @@ if __name__ == "__main__": status = True elif opt == "-v": verbose = True + elif opt == "-n": + numjobs = int(arg) else: print("Unknown option '", opt, "'.") @@ -254,12 +258,15 @@ if __name__ == "__main__": insertJobs(conn, cmds) if work: - while True: + n = 0 + while not numjobs or n < numjobs: + jobid = getNextJobId(conn) if jobid == None: print("All jobs have been started.") break processJob(conn, jobid) + n += 1 conn.close() -- 2.39.5