def loseConnection(self):
        if self.disconnecting:
            # print 'omg wtf loseConnection!???!'
            return
        self.disconnecting = True
        d = self.q2q.callRemoteString('close', id=str(self.id))
        def cbClosed(ignored):
            self.connectionLost(Failure(CONNECTION_DONE))
        def ebClosed(reason):
            if self.id in self.q2q.connections:
                self.connectionLost(reason)
            elif not reason.check(error.ConnectionDone):
                # Anything but a ConnectionDone (or similar things, perhaps)
                # is fishy.  Like an IndexError, that'd be wacko.  But a
                # ConnectionDone when self.id is already out of the Q2Q's
                # connections mapping means the connection was closed after
                # we thought it was supposed to be closed.  No harm there.
                log.err(reason, "Close virtual #%d failed" % (self.id,))
        d.addCallbacks(cbClosed, ebClosed)
dataset/ETHPy150Open twisted/vertex/vertex/q2q.py/VirtualTransport.loseConnection/original