"""
usage: teuthology-dispatcher --help
teuthology-dispatcher --supervisor [-v] --bin-path BIN_PATH --job-config COFNFIG --archive-dir DIR
- teuthology-dispatcher [-v] [--archive-dir DIR] --log-dir LOG_DIR --tube TUBE
+ teuthology-dispatcher [-v] [--archive-dir DIR] [--exit-on-empty-queue] --log-dir LOG_DIR --tube TUBE
Start a dispatcher for the specified tube. Grab jobs from a beanstalk
queue and run the teuthology tests they describe as subprocesses. The
--supervisor run dispatcher in job supervisor mode
--bin-path BIN_PATH teuthology bin path
--job-config CONFIG file descriptor of job's config file
+ --exit-on-empty-queue if the queue is empty, exit
"""
import docopt
tube = args["--tube"]
log_dir = args["--log-dir"]
archive_dir = args["--archive-dir"]
+ exit_on_empty_queue = args["--exit-on-empty-queue"]
if archive_dir is None:
archive_dir = teuth_config.archive_base
stop()
load_config()
-
+ job_procs = set(filter(lambda p: p.poll() is None, job_procs))
job = connection.reserve(timeout=60)
if job is None:
+ if exit_on_empty_queue and not job_procs:
+ log.info("Queue is empty and no supervisor processes running; exiting!")
+ break
continue
- job_procs = set(filter(lambda p: p.poll() is None, job_procs))
-
# bury the job so it won't be re-run if it fails
job.bury()
job_id = job.jid