diff --git a/kombu/connection.py b/kombu/connection.py index 7e6a1368..ea972fb6 100644 --- a/kombu/connection.py +++ b/kombu/connection.py @@ -565,7 +565,7 @@ class Resource(object): self.setup() def setup(self): - raise NotImplementedError("subclass responsibilty") + pass def _add_when_empty(self): if self.limit and len(self._dirty) >= self.limit: @@ -731,11 +731,10 @@ class ConnectionPool(Resource): return PoolChannelContext(self, block) def setup(self): - if self.limit: - for i in xrange(self.limit): + if self.preload: + for _ in xrange(self.preload): conn = self.new() - if i < self.preload: - conn.connect() + conn.connect() self._resource.put_nowait(conn) def prepare(self, resource): @@ -756,9 +755,9 @@ class ChannelPool(Resource): def setup(self): channel = self.new() - for i in xrange(self.limit): - self._resource.put_nowait( - i < self.preload and channel() or channel) + if self.preload: + for i in xrange(self.preload): + self._resource.put_nowait(channel()) def prepare(self, channel): if callable(channel): diff --git a/kombu/pools.py b/kombu/pools.py index 2d9db861..6a0d1a80 100644 --- a/kombu/pools.py +++ b/kombu/pools.py @@ -20,11 +20,6 @@ class ProducerPool(Resource): def new(self): return lambda: self.create_producer() - def setup(self): - if self.limit: - for _ in xrange(self.limit): - self._resource.put_nowait(self.new()) - def prepare(self, p): if callable(p): p = p()