# -*- coding: utf-8 -*- from delay import DelayedJob from redis import Redis import jobs redis_connection = Redis() delayed_jobs = DelayedJob(redis_connection) print "Delay jobs.add(7, 13) on default queue for 30 seconds." delayed_jobs.seconds("default", 30, jobs.add, 7, 13) print "Delay jobs.multiply(5, 2) on high queue for 5 seconds." delayed_jobs.seconds("high", 5, jobs.multiply, 5, 2)
worker = Worker(map(Queue, listen)) worker.work() def delay_worker(): while True: print 'Enqueued %d Jobs.' % delayed_jobs.enqueue_delayed_jobs() try: time.sleep(5) except KeyboardInterrupt: print "Shutting Down" break pid_list = [] signal.signal(signal.SIGINT,sigint_handler) #redis_connection = Redis() delayed_jobs = DelayedJob(conn) if __name__ == '__main__': pool = multiprocessing.Pool(processes=5) pool.apply_async(delay_worker,) for i in xrange(3): pool.apply_async(soon_worker,) for i in multiprocessing.active_children(): print i pid_list.append(i.pid) pid_list.append(os.getpid()) pool.close() pool.join()
# -*- coding: utf-8 -*- from delay import DelayedJob from redis import Redis import time redis_connection = Redis() delayed_jobs = DelayedJob(redis_connection) while True: print 'Enqueued %d Jobs.' % delayed_jobs.enqueue_delayed_jobs() try: time.sleep(5) except KeyboardInterrupt: print "Shutting Down" break