'When we emit a ProtocolSwitchCommand, lock the protocol, but don\'t actually
switch to the new protocol unless an acknowledgement is received.  If
an error is received, switch back.'

def _doCommand(self, proto):

    d = super(ProtocolSwitchCommand, self)._doCommand(proto)
    proto._lockForSwitch()
    def switchNow(ign):
        innerProto = self.protoToSwitchToFactory.buildProtocol(proto.transport.getPeer())
        proto._switchTo(innerProto, self.protoToSwitchToFactory)
        return ign
    def handle(ign):
        proto._unlockFromSwitch()
        self.protoToSwitchToFactory.clientConnectionFailed(None, Failure(CONNECTION_LOST))
        return ign
    return d.addCallbacks(switchNow, handle)
