def connectTo(self, _sturdyOrURL, _cb, *args, **kwargs): """Establish (and maintain) a connection to a given PBURL. I establish a connection to the PBURL and run a callback to inform the caller about the newly-available RemoteReference. If the connection is lost, I schedule a reconnection attempt for the near future. If that one fails, I keep trying at longer and longer intervals (exponential backoff). I accept a callback which will be fired each time a connection attempt succeeds. This callback is run with the new RemoteReference and any additional args/kwargs provided to me. The callback should then use rref.notifyOnDisconnect() to get a message when the connection goes away. At some point after it goes away, the Reconnector will reconnect. The Tub must be running (i.e. Tub.startService()) when this is invoked. Future releases may relax this requirement. I return a Reconnector object. When you no longer want to maintain this connection, call the stopConnecting() method on the Reconnector. I promise to not invoke your callback after you've called stopConnecting(), even if there was already a connection attempt in progress. If you had an active connection before calling stopConnecting(), you will still have access to it, until it breaks on its own. (I will not attempt to break existing connections, I will merely stop trying to create new ones). All my Reconnector objects will be shut down when the Tub is stopped. Usage:: def _got_ref(rref, arg1, arg2): rref.callRemote('hello again') # etc rc = tub.connectTo(_got_ref, 'arg1', 'arg2') ... rc.stopConnecting() # later """ rc = Reconnector(_sturdyOrURL, _cb, args, kwargs) if self.running: rc.startConnecting(self) else: self.log("Tub.connectTo(%s) queued until Tub.startService called" % _sturdyOrURL, level=UNUSUAL) self.reconnectors.append(rc) return rc