Exemplo n.º 1
0
    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)
Exemplo n.º 2
0
    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
Exemplo n.º 3
0
 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()
Exemplo n.º 4
0
 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())
Exemplo n.º 5
0
 def stopConnecting(self):
     """Stop attempt to connect."""
     self.failIfNotConnected(error.UserError())
Exemplo n.º 6
0
 def handle_connecting_stopConnecting(self):
     self.connectionFailed(failure.Failure(error.UserError()))
Exemplo n.º 7
0
 def _windowClosed(self, reason=None):
     if not self.deferredResult.called:
         self.deferredResult.errback(netError.UserError("Window closed."))
Exemplo n.º 8
0
 def _cancelled(self):
     if not self.deferredResult.called:
         self.deferredResult.errback(netError.UserError("User hit Cancel."))
     self._loginDialog.destroy()