projects
/
paralleljobs.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Also print cmd when printing job no.
[paralleljobs.git]
/
paralleljobs.py
diff --git
a/paralleljobs.py
b/paralleljobs.py
index f2e6eea15828b9c080945232db2b4d8e10c8dd92..6eb92dda40b803a9543ea161360170e4f50ead0a 100755
(executable)
--- a/
paralleljobs.py
+++ b/
paralleljobs.py
@@
-66,12
+66,13
@@
def runCmd(cmd):
return exitcode, out, err
def processJob(conn, jobid):
return exitcode, out, err
def processJob(conn, jobid):
- print("Process job %d" % (jobid))
c = conn.cursor()
c.execute("SELECT cmd FROM jobs WHERE id=?", (jobid,))
cmd, = c.fetchone()
c = conn.cursor()
c.execute("SELECT cmd FROM jobs WHERE id=?", (jobid,))
cmd, = c.fetchone()
+ print("Process job %d: %s" % (jobid, cmd))
+
ec, out, err = runCmd(cmd)
c.execute("UPDATE jobs SET exitcode=?, done=1 WHERE id=?;", (ec, jobid))
ec, out, err = runCmd(cmd)
c.execute("UPDATE jobs SET exitcode=?, done=1 WHERE id=?;", (ec, jobid))
@@
-166,6
+167,7
@@
COMMANDS:
OPTIONS:
-d database the database to process
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
-p cols-def create properties table with SQL column spec
-v print output of the job's command
@@
-206,9
+208,10
@@
if __name__ == "__main__":
propdef = None
work = False
status = False
propdef = None
work = False
status = False
+ numjobs = None
try:
try:
- opts, args = getopt.getopt(sys.argv[1:], "hd:c:p:wsv")
+ opts, args = getopt.getopt(sys.argv[1:], "hd:c:p:wsv
n:
")
for opt, arg in opts:
if opt == "-h":
for opt, arg in opts:
if opt == "-h":
@@
-226,6
+229,8
@@
if __name__ == "__main__":
status = True
elif opt == "-v":
verbose = True
status = True
elif opt == "-v":
verbose = True
+ elif opt == "-n":
+ numjobs = int(arg)
else:
print("Unknown option '", opt, "'.")
else:
print("Unknown option '", opt, "'.")
@@
-254,12
+259,15
@@
if __name__ == "__main__":
insertJobs(conn, cmds)
if work:
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)
jobid = getNextJobId(conn)
if jobid == None:
print("All jobs have been started.")
break
processJob(conn, jobid)
+ n += 1
conn.close()
conn.close()