def thunkify(thread_name=None, daemon=True, default_func=None):
def actual_decorator(f):<EOL><INDENT>@functools.wraps(f)<EOL>def thunked(*args, **kwargs):<EOL><INDENT>result = [None]<EOL>exc = [False, None]  <EOL><INDENT>wait_event = threading.Event()<EOL><DEDENT>def worker_func():<EOL><INDENT>try:<EOL><INDENT>func_result = f(*args, **kwargs)<EOL>result[<NUM_LIT:0>] = func_result<EOL><DEDENT>except Exception:<EOL><INDENT>exc[<NUM_LIT:0>] = True<EOL>exc[<NUM_LIT:1>] = sys.exc_info()<EOL>logging.error("<STR_LIT>", thread_name, traceback.format_exc())<EOL>
Make a function immediately return a function of no args which, when called,
    waits for the result, which will start being processed in another thread.
    Taken from https://wiki.python.org/moin/PythonDecoratorLibrary.