limitations under the License.
self._watching = set(['default']) # set of watched tubes
+ self._reconnect_cb = None
# wait some time before trying to re-connect
elif self._using != 'default':
+ # change the tube used, and callback to user
+ self.use(self._using, self._reconnect_cb)
+ elif self._reconnect_cb:
# ignored, as next re-connect will retry the operation
self._stream.connect((self.host, self.port), callback)
+ def set_reconnect_callback(self, callback):
+ """Set callback to be called if connection has been lost and
+ If the connection is closed unexpectedly, the client will automatically
+ attempt to re-connect with 1 second intervals. After re-connecting, the
+ client will attempt to re-establish the used tube and watched tubes.
+ self._reconnect_cb = callback
def close(self, callback=None):
"""Close connection to server."""