def test_endpointConnectingCancelled(self): """ Calling L{Deferred.cancel} on the L{Deferred} returned from L{IStreamClientEndpoint.connect} is errbacked with an expected L{ConnectingCancelledError} exception. """ mreactor = MemoryReactor() clientFactory = object() ep, ignoredArgs, address = self.createClientEndpoint( mreactor, clientFactory) d = ep.connect(clientFactory) receivedFailures = [] def checkFailure(f): receivedFailures.append(f) d.addErrback(checkFailure) d.cancel() # When canceled, the connector will immediately notify its factory that # the connection attempt has failed due to a UserError. attemptFactory = self.retrieveConnectedFactory(mreactor) attemptFactory.clientConnectionFailed(None, Failure(error.UserError())) # This should be a feature of MemoryReactor: <http://tm.tl/5630>. self.assertEqual(len(receivedFailures), 1) failure = receivedFailures[0] self.assertIsInstance(failure.value, error.ConnectingCancelledError) self.assertEqual(failure.value.address, address)
def stopConnecting(self): """Stop attempting to connect.""" if self.state != "connecting": raise error.NotConnectingError, "we're not trying to connect" self.state = "disconnected" self.transport.failIfNotConnected(error.UserError()) del self.transport
def stopConnecting(self): if self._started: self.connector.stopConnecting() self._cleanup() return self.reactor.drop_postponed(self) # for accuracy self.factory.startedConnecting(self) abort = failure.Failure(error.UserError(string="Connection preempted")) self.factory.clientConnectionFailed(self, abort) self._cleanup()
def stopConnecting(self): """ If a connection attempt is still outstanding (i.e. no connection is yet established), immediately stop attempting to connect. """ self.failIfNotConnected(error.UserError())
def stopConnecting(self): """Stop attempt to connect.""" self.failIfNotConnected(error.UserError())
def handle_connecting_stopConnecting(self): self.connectionFailed(failure.Failure(error.UserError()))
def _windowClosed(self, reason=None): if not self.deferredResult.called: self.deferredResult.errback(netError.UserError("Window closed."))
def _cancelled(self): if not self.deferredResult.called: self.deferredResult.errback(netError.UserError("User hit Cancel.")) self._loginDialog.destroy()