mirror of https://github.com/celery/kombu.git
Fixes simple task queue example. Closes #230
This commit is contained in:
parent
427b563ce9
commit
76470da7ce
|
@ -13,11 +13,11 @@ def send_as_task(connection, fun, args=(), kwargs={}, priority='mid'):
|
|||
routing_key = priority_to_routing_key[priority]
|
||||
|
||||
with producers[connection].acquire(block=True) as producer:
|
||||
maybe_declare(task_exchange, producer.channel)
|
||||
producer.publish(payload,
|
||||
serializer='pickle',
|
||||
compression='bzip2',
|
||||
exchange=task_exchange,
|
||||
declare=[task_exchange],
|
||||
routing_key=routing_key)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -14,6 +14,7 @@ class Worker(ConsumerMixin):
|
|||
|
||||
def get_consumers(self, Consumer, channel):
|
||||
return [Consumer(queues=task_queues,
|
||||
accept=['pickle', 'json'],
|
||||
callbacks=[self.process_task])]
|
||||
|
||||
def process_task(self, body, message):
|
||||
|
@ -30,10 +31,12 @@ class Worker(ConsumerMixin):
|
|||
if __name__ == '__main__':
|
||||
from kombu import Connection
|
||||
from kombu.utils.debug import setup_logging
|
||||
setup_logging(loglevel='INFO')
|
||||
# setup root logger
|
||||
setup_logging(loglevel='INFO', loggers=[''])
|
||||
|
||||
with Connection('amqp://guest:guest@localhost:5672//') as conn:
|
||||
try:
|
||||
Worker(conn).run()
|
||||
worker = Worker(conn)
|
||||
worker.run()
|
||||
except KeyboardInterrupt:
|
||||
print('bye bye')
|
||||
|
|
Loading…
Reference in New Issue