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):
|
def __exit__(self, *args):
|
||||||
self.release()
|
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
|
@property
|
||||||
def connection(self):
|
def connection(self):
|
||||||
"""The underlying connection object.
|
"""The underlying connection object.
|
||||||
|
@ -552,13 +559,11 @@ class BrokerConnection(object):
|
||||||
depend on the interface of this object.
|
depend on the interface of this object.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
if self._closed:
|
if not self._closed:
|
||||||
return
|
if not self.connected:
|
||||||
if not self._connection or not \
|
self._connection = self._establish_connection()
|
||||||
self.transport.verify_connection(self._connection):
|
self._closed = False
|
||||||
self._connection = self._establish_connection()
|
return self._connection
|
||||||
self._closed = False
|
|
||||||
return self._connection
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def default_channel(self):
|
def default_channel(self):
|
||||||
|
|
Loading…
Reference in New Issue