def api_fifo_read(self):
        """
            A thread which keeps reading an input fifo,
            specified in the api configs, each line it reads is expected to
            be a json string encoding a dict of the form
            {
                FIFO_ENDPOINT_KEY: fifo_endpoint,
                COMMAND_ID_KEY: command_id,
                COMMAND_KEY: command,
                ARGS_KEY: args,
                METHOD_KEY: method
            }
            fifo_endpoint - Input FIFO to api server
            command_id - the sequence id of the command
            command - the api command called (command along with method should
                                              map to a unique function in
                                              moirai class)
            args - arugments for the command
            method - api method name (GET/PUT/POST)

            Args:
                None
            Return:
                None
            Raise:
                IOError/OSError - Unable to open input FIFO
        """
        try:
            if not os.path.exists(self.api_config['moirai_input_fifo']):
                os.mkfifo(self.api_config['moirai_input_fifo'])
            print("\nAPI FIFO open for read\n")
            self.fifo_fd = open(self.api_config['moirai_input_fifo'])
        except (IOError, OSError):
            print ("[Error] Unable to read api input FIFO")
            raise
        while True:
            skip_iteration_flag = False
            request_json = self.fifo_fd.readline()
            if request_json:
                try:
                    # if request_json:
                    request_map = json.loads(request_json)
                except ValueError:
                    print ("[Error] Recieved non json object, skipping")
                    print(request_json)
                    continue
                required_keys = [ApiConstants.FIFO_ENDPOINT_KEY,
                                 ApiConstants.COMMAND_ID_KEY,
                                 ApiConstants.COMMAND_KEY,
                                 ApiConstants.ARGS_KEY,
                                 ApiConstants.METHOD_KEY]
                for arr_key in required_keys:
                    if arr_key not in request_map.keys():
                        print ("[Error] Malformed message missing {}"
                               .format(arr_key))
                        skip_iteration_flag = True

                if skip_iteration_flag:
                    continue

                fifo_endpoint = request_map[ApiConstants.FIFO_ENDPOINT_KEY]
                command_id = request_map[ApiConstants.COMMAND_ID_KEY]
                command = request_map[ApiConstants.COMMAND_KEY]
                args = request_map[ApiConstants.ARGS_KEY]
                method = request_map[ApiConstants.METHOD_KEY]
                if ApiConstants.API_COMMANDS not in command:
                    output_msg = {ApiConstants.COMMAND_ID_KEY: command_id,
                                  ApiConstants.COMMAND_OUTPUT_KEY:
                                  "No such command found"}
                else:
                    if method == "GET":
                        moirai_function = (ApiConstants.
                                           MOIRAI_GET_COMMAND_PREFIX +
                                           command)
                    else:
                        moirai_function = (ApiConstants.
                                           MOIRAI_OTHER_COMMAND_PREFIX +
                                           command)
                try:
                    command_handler = getattr(self, moirai_function)
                    command_output = command_handler(args)
                    output_msg = {ApiConstants.COMMAND_ID_KEY: command_id,
                                  ApiConstants.COMMAND_OUTPUT_KEY:
                                  command_output}
                except:
                    output_msg = {ApiConstants.COMMAND_ID_KEY: command_id,
                                  ApiConstants.COMMAND_OUTPUT_KEY:
                                  "Unexpected error in moirai"}
                with open(fifo_endpoint, 'w') as output_fd:
                    output_fd.write(json.dumps(output_msg))
dataset/ETHPy150Open linkedin/simoorg/src/test/mock_modules/MockMoirai.py/MockMoirai.api_fifo_read/swapped operands of `not in`