示例#1
0
def delete_buried(server, port, tube, jobCounter):
    client = BeanstalkClient(server, port)
    client.watch(tube)
    client.use(tube)
    while True:
        try:
            for job in client.peek_buried_iter():
                client.delete_job(job.job_id)
                jobCounter.increment_buried()
            kicked = jobCounter.buried()
            time.sleep(1)
            if kicked == jobCounter.buried():
                break
        except BeanstalkError:
            break
        except KeyboardInterrupt:
            break
示例#2
0
def delete_ready(server, port, tube, jobCounter):
    client = BeanstalkClient(server, port)
    client.watch(tube)
    client.use(tube)

    while True:
        try:
            for job in client.reserve_iter():
                client.delete_job(job.job_id)
                jobCounter.increment_ready()
            processed = jobCounter.abs()
            time.sleep(1)
            if processed == jobCounter.abs():
                break
        except BeanstalkError:
            break
        except KeyboardInterrupt:
            break