Merge pull request #11 from bninja/cxn-str
fix cxn str to work w/ pika.BlockingConnection
This commit is contained in:
commit
5b1d3b6503
17
pika_pool.py
17
pika_pool.py
|
@ -231,9 +231,22 @@ class Pool(object):
|
|||
if not Connection.is_connection_invalidated(ex):
|
||||
raise
|
||||
|
||||
@property
|
||||
def cxn_params(self):
|
||||
if isinstance(self.cxn, pika.BaseConnection):
|
||||
return self.cxn.params
|
||||
if isinstance(self.cxn, pika.BlockingConnection):
|
||||
return self.cxn._impl.params
|
||||
|
||||
@property
|
||||
def cxn_str(self):
|
||||
params = self.cxn_params
|
||||
if params:
|
||||
return '{0}:{1}/{2}'.format(params.host, params.port, params.virtual_host)
|
||||
|
||||
def __str__(self):
|
||||
return ', '.join('{0}={1}'.format(k, v) for k, v in [
|
||||
('cxn', '{0}:{1}/{2}'.format(self.cxn.params.host, self.cxn.params.port, self.cxn.params.virtual_host)),
|
||||
('cxn', self.cxn_str),
|
||||
('channel', '{0}'.format(int(self.channel) if self.channel is not None else self.channel)),
|
||||
])
|
||||
|
||||
|
@ -358,7 +371,7 @@ class QueuedPool(Pool):
|
|||
|
||||
def __str__(self):
|
||||
return ', '.join('{0}={1}'.format(k, v) for k, v in [
|
||||
('cxn', '{0}:{1}/{2}'.format(self.cxn.params.host, self.cxn.params.port, self.cxn.params.virtual_host)),
|
||||
('cxn', self.cxn_str),
|
||||
('channel', '{0}'.format(int(self.channel) if self.channel is not None else self.channel)),
|
||||
('created_at', '{0}'.format(datetime.fromtimestamp(self.created_at).isoformat())),
|
||||
('released_at', '{0}'.format(datetime.fromtimestamp(self.released_at).isoformat())),
|
||||
|
|
Loading…
Reference in New Issue