I'm trying to get a basic queue system with rabbitmq, but when I try to use threads, it only seems to run 1 thread.
my code:
import pika
import threading
rabbit_url = "amqp://user:pass!@127.0.0.1:5672/%2f"
def start(max_threads):
for i in xrange(max_threads):
t = threading.Thread(target=run)
t.start()
t.join()
def run():
connection = pika.BlockingConnection(pika.URLParameters(rabbit_url))
channel = connection.channel()
channel.basic_consume(callback,
queue='docketq',
no_ack=True)
channel.start_consuming()
def callback(ch, method, properties, body):
do_work(body)
def do_work(body):
print body