code: def connectionLost(self, reason=protocol.connectionDone):
          
          self.connected = 0
  
          for pending in self._queue.values():
              pending.errback(reason)
          self._queue.clear()
  
          if self._stopped:
              result = self if reason.check(error.ConnectionDone) else reason
              self._stopped.callback(result)
              self._stopped = None
          else:
              reason.raiseException()
docs: Check whether termination was intended and invoke the deferred.
  
          If the connection terminated unexpectedly, reraise the failure.
  
          @type reason: L{twisted.python.failure.Failure}