twisted.internet.main.CONNECTION_DONE - python examples

Here are the examples of the python api twisted.internet.main.CONNECTION_DONE taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

23 Examples 7

3 View Complete Implementation : abstract.py
Copyright MIT License
Author : adde88
    def handle_connected_loseConnection(self):
        self.stopReading()
        if self.writing:
            self.addBufferCallback(self._cbDisconnecting, "buffer empty")
            self.state = "disconnecting"
        else:
            self.reactor.callLater(0, self.connectionLost, failure.Failure(main.CONNECTION_DONE))

3 View Complete Implementation : abstract.py
Copyright MIT License
Author : adde88
    def startReading(self):
        if self.state != "connected":
            return
        self.reading = True
        while self.producerBuffer:
            item = self.producerBuffer.pop(0)
            self.protocol.dataReceived(item)
            if not self.reading:
                return
        try:
            self.read_op.initiateOp(self.socket.fileno(), self.readbuf)
        except WindowsError, we:
#            log.msg("initiating read failed with args %s" % (we,))
            self.reactor.callLater(0, self.connectionLost, failure.Failure(main.CONNECTION_DONE))

3 View Complete Implementation : abstract.py
Copyright MIT License
Author : adde88
    def startWriting(self):
        self.writing = True
        b = buffer(self.writebuf[0], self.offset)
#        ll = map(len, self.writebuf)
#        log.msg("buffer lengths are", ll, "total", sum(ll))
        try:
            self.write_op.initiateOp(self.socket.fileno(), b)
        except WindowsError, we:
#            log.msg("initiating write failed with args %s" % (we,))
            self.reactor.callLater(0, self.connectionLost, failure.Failure(main.CONNECTION_DONE))

3 View Complete Implementation : _win32stdio.py
Copyright MIT License
Author : adde88
    def checkConnLost(self):
        self.connsLost += 1
        if self.connsLost >= 2:
            self.disconnecting = True
            self.disconnected = True
            self.proto.connectionLost(main.CONNECTION_DONE)

3 View Complete Implementation : loopback.py
Copyright MIT License
Author : adde88
    def clearBuffer(self):
        if self.shouldLose == -1:
            return
        
        if self.producer:
            self.producer.resumeProducing()
        if self.buffer:
            if self.logFile:
                self.logFile.write("loopback receiving %s\n" % repr(self.buffer))
            buffer = self.buffer
            self.buffer = ''
            self.target.dataReceived(buffer)
        if self.shouldLose == 1:
            self.shouldLose = -1
            self.target.connectionLost(failure.Failure(main.CONNECTION_DONE))

3 View Complete Implementation : test_pb.py
Copyright MIT License
Author : adde88
    def testImmediateClose(self):
        """
        Test that if a Broker loses its connection without receiving any bytes,
        it doesn't raise any exceptions or log any errors.
        """
        serverProto = self.factory.buildProtocol(('127.0.0.1', 12345))
        serverProto.makeConnection(protocol.FileWrapper(StringIO()))
        serverProto.connectionLost(failure.Failure(main.CONNECTION_DONE))

3 View Complete Implementation : abstract.py
Copyright MIT License
Author : wistbean
    def _postLoseConnection(self):
        """Called after a loseConnection(), when all data has been written.

        Whatever this returns is then returned by doWrite.
        """
        # default implementation, telling reactor we're finished
        return main.CONNECTION_DONE

3 View Complete Implementation : _win32stdio.py
Copyright MIT License
Author : wistbean
    def checkConnLost(self):
        self.connsLost += 1
        if self.connsLost >= 2:
            self.disconnecting = True
            self.disconnected = True
            self.proto.connectionLost(Failure(main.CONNECTION_DONE))

3 View Complete Implementation : loopback.py
Copyright MIT License
Author : wistbean
    def clearBuffer(self):
        if self.shouldLose == -1:
            return

        if self.producer:
            self.producer.resumeProducing()
        if self.buffer:
            if self.logFile:
                self.logFile.write("loopback receiving %s\n" % repr(self.buffer))
            buffer = self.buffer
            self.buffer = b''
            self.target.dataReceived(buffer)
        if self.shouldLose == 1:
            self.shouldLose = -1
            self.target.connectionLost(failure.Failure(main.CONNECTION_DONE))

0 View Complete Implementation : abstract.py
Copyright MIT License
Author : adde88
    def _cbDisconnecting(self):
        if self.producer:
            return
        self.removeBufferCallback(self._cbDisconnecting, "buffer empty")
        self.connectionLost(failure.Failure(main.CONNECTION_DONE))