r46819 - shorter stub

glyph-TA+aISz0psMTMxyoc4vAAJOcrHinNvQL0E9HWUfgJXw@public.gmane.org
Newsgroups gmane.comp.python.twisted.commits
Message-ID <[email protected]>
Author: glyph
Date: Thu Feb 18 01:36:10 2016
New Revision: 46819

Modified:
   branches/persistent-client-service-4735-5/twisted/application/internet.py

Log:
shorter stub

Modified: branches/persistent-client-service-4735-5/twisted/application/internet.py
==============================================================================
--- branches/persistent-client-service-4735-5/twisted/application/internet.py	(original)
+++ branches/persistent-client-service-4735-5/twisted/application/internet.py	Thu Feb 18 01:36:10 2016
@@ -510,16 +510,13 @@
 
 
 
-class _StubDelayedCall(object):
+def _noop():
     """
-    An object with a C{cancel} method, to stand in for a delayed call.
+    Do nothing; this stands in for C{transport.loseConnection()} and
+    C{DelayedCall.cancel()} when L{ClientService} is in a state where there's
+    nothing to do.
     """
 
-    @staticmethod
-    def cancel():
-        """
-        Do nothing.
-        """
 
 
 class ClientService(service.Service, object):
@@ -560,10 +557,10 @@
         self._factory = factory
         self._timeoutForAttempt = retryPolicy
         self._clock = clock
-        self._delayedRetry = _StubDelayedCall
+        self._stopRetry = _noop
         self._lostDeferred = succeed(None)
         self._connectionInProgress = succeed(None)
-        self._loseConnection = lambda: None
+        self._loseConnection = _noop
 
         self._currentConnection = None
         self._awaitingConnected = []
@@ -615,7 +612,7 @@
         factoryProxy = _DisconnectFactory(self._factory, clientDisconnect)
 
         def connectNow():
-            self._delayedRetry = _StubDelayedCall
+            self._stopRetry = _noop
             self._connectionInProgress = (self._endpoint.connect(factoryProxy)
                                           .addCallback(clientConnect)
                                           .addErrback(retry))
@@ -628,7 +625,7 @@
             self._log.info("Scheduling retry {attempt} to connect {endpoint} "
                            "in {delay} seconds.", attempt=self._failedAttempts,
                            endpoint=self._endpoint, delay=delay)
-            self._delayedRetry = self._clock.callLater(delay, connectNow)
+            self._stopRetry = self._clock.callLater(delay, connectNow).cancel
 
         connectNow()
 
@@ -641,8 +638,8 @@
             closed and all in-progress connection attempts halted.
         """
         super(ClientService, self).stopService()
-        self._delayedRetry.cancel()
-        self._delayedRetry = _StubDelayedCall
+        self._stopRetry()
+        self._stopRetry = _noop
         self._connectionInProgress.cancel()
         self._loseConnection()
         return gatherResults([self._connectionInProgress, self._lostDeferred])
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.