def testLoopback(self): protocol = MyVirtualPOP3() protocol.service = self.factory clientProtocol = MyPOP3Downloader() loopback.loopback(protocol, clientProtocol) self.failUnlessEqual(clientProtocol.message, self.message) protocol.connectionLost(failure.Failure(Exception("Test harness disconnect")))
def testLoopback(self): protocol = MyVirtualPOP3() protocol.service = self.factory clientProtocol = MyPOP3Downloader() loopback.loopback(protocol, clientProtocol) self.failUnlessEqual(clientProtocol.message, self.message) protocol.connectionLost( failure.Failure(Exception("Test harness disconnect")))
def removeProtocol(self, protocol): if protocol in self._protocols: log.msg('_EpicsBufferSubscriptionProtocol: removeProtocol: Remove protocol: %(p)s', p=protocol, logLevel=_DEBUG) # Do not unsubscribe, the buffer will live for the life of the server! Maybe a timeout is required instead. protocol.connectionLost("Connection closed cleanly") self._protocols.remove(protocol) else: log.msg('_EpicsBufferSubscriptionProtocol: removeProtocol: Protocol not found %(p)s', p=protocol, logLevel=_WARN)
def connectionLost(self, reason): """See abstract.FileDescriptor.connectionLost(). """ abstract.FileDescriptor.connectionLost(self, reason) self._closeSocket() protocol = self.protocol del self.protocol del self.socket del self.fileno protocol.connectionLost(reason)
def removeProtocol(self, protocol): if protocol in self._protocols: log.msg('EpicsSubscriptionProtocol: removeProtocol: Remove protocol: %(p)s', p=protocol, logLevel=_DEBUG) protocol.connectionLost("Connection closed cleanly") self._protocols.remove(protocol) if len(self._protocols) == 0: log.msg('EpicsSubscriptionProtocol: removeProtocol: No protocols remaining, so loseConnection', logLevel=_DEBUG) self.transport.loseConnection() self._subscription.unsubscribe() else: log.msg('EpicsSubscriptionProtocol: removeProtocol: Protocol not found %(p)s', p=protocol, logLevel=_WARN)
def connectionLost(self, reason): """See abstract.FileDescriptor.connectionLost(). """ abstract.FileDescriptor.connectionLost(self, reason) self._closeSocket() protocol = self.protocol del self.protocol del self.socket del self.fileno try: protocol.connectionLost(reason) except TypeError, e: # while this may break, it will only break on deprecated code # as opposed to other approaches that might've broken on # code that uses the new API (e.g. inspect). if e.args and e.args[0] == "connectionLost() takes exactly 1 argument (2 given)": warnings.warn("Protocol %s's connectionLost should accept a reason argument" % protocol, category=DeprecationWarning, stacklevel=2) protocol.connectionLost() else: raise
def connectionLost(self, reason): self._connected = False log.msg('DistributingProtocol: connectionLost: Reason is %(r)s', r=reason, logLevel=_TRACE) for protocol in self._protocols: log.msg('DistributingProtocol: connectionLost: Distribute to %(p)s', p=protocol, logLevel=_TRACE) protocol.connectionLost(reason)
def check(ignored): self.assertEqual(clientProtocol.message, self.message) protocol.connectionLost( failure.Failure(Exception("Test harness disconnect")))