Skip to content

Commit

Permalink
Merge branch 'master' of github.com:chexov/queueit
Browse files Browse the repository at this point in the history
  • Loading branch information
Anton P. Linevich committed Jan 25, 2011
2 parents 6ed2f3d + 6eb8f74 commit bc283f5
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions queueit
Expand Up @@ -151,9 +151,11 @@ def qwrapperbatch(tube_in, tube_out, worker_cmd, batch_size=10):
LOG.info(u"Timeout reached")
batch_jobs.append(job)
except DeadlineSoon:
LOG.debug(u"Oops. Got DeadlineSoon. Touching reserved jobs..")
LOG.debug(u"Oops. Got DeadlineSoon. Do not waiting for queue to fill up..")
#LOG.debug(u"Oops. Got DeadlineSoon. Touching reserved jobs..")
map(lambda j: j.touch(), batch_jobs)
continue
break
#continue

cmd.extend(map(lambda j: j.body, batch_jobs))

Expand Down Expand Up @@ -183,7 +185,6 @@ def qwrapper(tube_in, tube_out, worker_cmd):
qconn_out.use(tube_out)

LOG.info(u"QHOST: %s, QPORT %s, TTR %s, Watching queues: %s" % (QHOST, QPORT, QTTR, qconn_in.watching()) )

while True:
job = qconn_in.reserve(timeout=QTIMEOUT)
if not job:
Expand All @@ -195,11 +196,11 @@ def qwrapper(tube_in, tube_out, worker_cmd):
if u" ".join(worker_cmd).find('{}') > -1:
cmd = map(lambda arg: arg.replace('{}', job.body), worker_cmd)
else:
cmd = worker_cmd
cmd = list(worker_cmd)
cmd.append(job.body)

LOG.debug(u"Calling command '%s'" % u" ".join(cmd))
retcode = subprocess.call(cmd, shell=True)
retcode = subprocess.call(cmd)
if not retcode == 0:
LOG.error(u"Worker command '%s' was exited with retcode %s" % (cmd, retcode) )
job.bury()
Expand Down Expand Up @@ -261,9 +262,7 @@ if __name__ == "__main__":
else:
qstat()
elif COMMAND == 'q-wrapper':
if len(args) == 2:
qwrapper(args[0], args[1], worker_cmd=[sys.stdin.readline()])
elif len(args) >= 3:
if len(args) >= 3:
qwrapper(args[0], args[1], worker_cmd=args[2:])
else:
print "Usage: %s <queue-in> <queue-out> [<cmd>]\n <cmd> could be sent trough STDIN" % (COMMAND)
Expand Down

0 comments on commit bc283f5

Please sign in to comment.