mirror of https://github.com/celery/kombu.git
Adds BrokerConnection.connected
This method returns True if the connection object has actually established a connection, and is not closed.
This commit is contained in:
parent
81dd557f46
commit
412a1b15d4
|
@ -543,6 +543,13 @@ class BrokerConnection(object):
|
|||
def __exit__(self, *args):
|
||||
self.release()
|
||||
|
||||
@property
|
||||
def connected(self):
|
||||
"""Returns true if the connection has been established."""
|
||||
return (not self._closed and
|
||||
self._connection is not None and
|
||||
self.transport.verify_connection(self._connection))
|
||||
|
||||
@property
|
||||
def connection(self):
|
||||
"""The underlying connection object.
|
||||
|
@ -552,13 +559,11 @@ class BrokerConnection(object):
|
|||
depend on the interface of this object.
|
||||
|
||||
"""
|
||||
if self._closed:
|
||||
return
|
||||
if not self._connection or not \
|
||||
self.transport.verify_connection(self._connection):
|
||||
self._connection = self._establish_connection()
|
||||
self._closed = False
|
||||
return self._connection
|
||||
if not self._closed:
|
||||
if not self.connected:
|
||||
self._connection = self._establish_connection()
|
||||
self._closed = False
|
||||
return self._connection
|
||||
|
||||
@property
|
||||
def default_channel(self):
|
||||
|
|
Loading…
Reference in New Issue