def testKeywordWorker(self): import tests self.dreque.enqueue("test", tests.test_func, tempfile=self.tempfile, text="worker_test") worker = DrequeWorker(["test"], db=self.db) worker.work(0) self.failUnlessEqual(self._get_output(), "worker_test")
def testPositionalWorker(self): self.dreque.enqueue("test", tests.test_func, self.tempfile, "worker_test") worker = DrequeWorker(["test"], db=self.db) worker.work(0) self.assertEqual(self._get_output(), b"worker_test") self.assertEqual(self.dreque.stats.get("processed"), 1)
def testPositionalWorker(self): import tests self.dreque.enqueue("test", tests.test_func, self.tempfile, "worker_test") worker = DrequeWorker(["test"], "127.0.0.1", db=self.db) worker.work(0) self.failUnlessEqual(self._get_output(), "worker_test") self.failUnlessEqual(self.dreque.stats.get("processed"), 1)
def main(): if os.path.isdir('/var/run'): pidfile = open('/var/run/build_consumer.pid', 'w') pidfile.write(str(os.getpid())) pidfile.close() brickconfig = BrickConfig() worker = DrequeWorker(['build'], brickconfig.get('redis', 'redis-server')) worker.work()
def testKeywordWorker(self): import tests self.dreque.enqueue("test", tests.test_func, tempfile=self.tempfile, text="worker_test") worker = DrequeWorker(["test"], db=self.db) worker.work(0) self.assertEqual(self._get_output(), b"worker_test")
def consume_taskqueue(): worker = DrequeWorker(["queue"], (ip,6379),db=6) worker.work(0.0001)#TODO:why use 0 will escape,only execute once?
def worker(): logging.getLogger("dreque.worker").setLevel(logging.CRITICAL) w = DrequeWorker(["test"], db=self.db) w.work(0.1)
def worker(): import logging logging.getLogger("dreque.worker").setLevel(logging.CRITICAL) w = DrequeWorker(["test"], "127.0.0.1", db=self.db) w.work(0)
def testKeywordWorker(self): import tests self.dreque.enqueue("test", tests.set_something, val="worker_test") worker = DrequeWorker(["test"], "127.0.0.1", nofork=True) worker.work(0) self.failUnlessEqual(tests.something, "worker_test")
def worker(): w = DrequeWorker(["test"], db=self.db) w.work(0)
def worker(): #import logging #logging.getLogger("dreque.worker").setLevel(logging.CRITICAL) w = DrequeWorker(["queue"], (ip,6379),db=6) w.work(0.01)#队列轮询间隔的时间,默认是5s
def worker(): w = DrequeWorker(["test"], "127.0.0.1", db=self.db) w.work(0)
def main(): brickconfig = BrickConfig() worker = DrequeWorker(['build'], brickconfig.get('redis', 'redis-server')) worker.work()
from dreque import DrequeWorker from redis import StrictRedis def long_crypt_job(rand, uid): print 'request uid: %d' % uid result = 1 for i in range(1, rand): result *= i print 'job done: %d! = %s\n' % (rand, result) StrictRedis().set(uid, result) worker = DrequeWorker(['queue'], 'localhost') worker.work()