mirror of https://github.com/celery/kombu.git
ProducerPool.Producer: can be used to override the producer type used
This commit is contained in:
parent
20ef0d1790
commit
a717b6c723
|
@ -14,17 +14,16 @@ def register_group(group):
|
||||||
|
|
||||||
|
|
||||||
class ProducerPool(Resource):
|
class ProducerPool(Resource):
|
||||||
Producer = Producer
|
|
||||||
|
|
||||||
def __init__(self, connections, *args, **kwargs):
|
def __init__(self, connections, *args, **kwargs):
|
||||||
self.connections = connections
|
self.connections = connections
|
||||||
super(ProducerPool, self).__init__(*args, **kwargs)
|
super(ProducerPool, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
def Producer(self, connection):
|
||||||
|
return Producer(connection)
|
||||||
|
|
||||||
def create_producer(self):
|
def create_producer(self):
|
||||||
conn = self.connections.acquire(block=True)
|
return self.Producer(self.connections.acquire(block=True))
|
||||||
producer = self.Producer(conn)
|
|
||||||
producer.connection = conn
|
|
||||||
return producer
|
|
||||||
|
|
||||||
def new(self):
|
def new(self):
|
||||||
return lambda: self.create_producer()
|
return lambda: self.create_producer()
|
||||||
|
|
Loading…
Reference in New Issue