def runner(incoming_q, outgoing_q):
logger.debug("<STR_LIT>")<EOL>def execute_task(bufs):<EOL><INDENT>"""<STR_LIT>"""<EOL>user_ns = locals()<EOL>user_ns.update({'<STR_LIT>': __builtins__})<EOL>f, args, kwargs = unpack_apply_message(bufs, user_ns, copy=False)<EOL>fname = getattr(f, '<STR_LIT>', '<STR_LIT:f>')<EOL>prefix = "<STR_LIT>"<EOL>fname = prefix + "<STR_LIT:f>"<EOL>argname = prefix + "<STR_LIT:args>"<EOL>kwargname = prefix + "<STR_LIT>"<EOL>resultname = prefix + "<STR_LIT:result>"<EOL>user_ns.update({fname: f,<EOL>argname: args,<EOL>kwargname: kwargs,<EOL>resultname: resultname})<EOL>code = "<STR_LIT>".format(resultname, fname,<EOL>argname, kwargname)<EOL>try:<EOL><INDENT>logger.debug("<STR_LIT>".format(code))<EOL>exec(code, user_ns, user_ns)<EOL><DEDENT>except Exception as e:<EOL><INDENT>logger.warning("<STR_LIT>".format(e))<EOL>raise e<EOL><DEDENT>else:<EOL><INDENT>logger.debug("<STR_LIT>".format(user_ns.get(resultname)))<EOL>return user_ns.get(resultname)<EOL><DEDENT><DEDENT>while True:<EOL><INDENT>try:<EOL><INDENT>msg = incoming_q.get(block=True, timeout=<NUM_LIT:10>)<EOL><DEDENT>except queue.Empty:<EOL><INDENT>logger.debug("<STR_LIT>")<EOL><DEDENT>except IOError as e:<EOL><INDENT>logger.debug("<STR_LIT>".format(e))<EOL>try:<EOL><INDENT>outgoing_q.put(None)<EOL><DEDENT>except Exception:<EOL><INDENT>pass<EOL><DEDENT>break<EOL><DEDENT>except Exception as e:<EOL><INDENT>logger.debug("<STR_LIT>".format(e))<EOL><DEDENT>else:<EOL><INDENT>if not msg:<EOL><INDENT>logger.debug("<STR_LIT>")<EOL>outgoing_q.put(None)<EOL>break<EOL><DEDENT>else:<EOL><INDENT>logger.debug("<STR_LIT>".format(msg["<STR_LIT>"]))<EOL>try:<EOL><INDENT>response_obj = execute_task(msg['<STR_LIT>'])<EOL>response = {"<STR_LIT>": msg["<STR_LIT>"],<EOL>"<STR_LIT:result>": serialize_object(response_obj)}<EOL>logger.debug("<STR_LIT>".format(<EOL>deserialize_object(response["<STR_LIT:result>"])))<EOL><DEDENT>except Exception as e:<EOL><INDENT>logger.debug("<STR_LIT>".format(e))<EOL>response = {"<STR_LIT>": msg["<STR_LIT>"],<EOL>"<STR_LIT>": serialize_object(e)}<EOL><DEDENT>outgoing_q.put(response)<EOL><DEDENT><DEDENT><DEDENT>logger.debug("<STR_LIT>")<EOL>
This is a function that mocks the Swift-T side.

    It listens on the the incoming_q for tasks and posts returns on the outgoing_q.

    Args:
         - incoming_q (Queue object) : The queue to listen on
         - outgoing_q (Queue object) : Queue to post results on

    The messages posted on the incoming_q will be of the form :

    .. code:: python

       {
          "task_id" : <uuid.uuid4 string>,
          "buffer"  : serialized buffer containing the fn, args and kwargs
       }

    If ``None`` is received, the runner will exit.

    Response messages should be of the form:

    .. code:: python

       {
          "task_id" : <uuid.uuid4 string>,
          "result"  : serialized buffer containing result
          "exception" : serialized exception object
       }

    On exiting the runner will post ``None`` to the outgoing_q