def _dispatch_remote(func_name, args, kwargs):
    """This receives the data on the remote side and calls
    the actual function that does the job and returns results.
    """

    g = globals()
    func_name_pre = '%s_remote_pre' % func_name
    func_name_post = '%s_remote_post' % func_name

    if func_name_pre in g:
        args = list(args)
        g[func_name_pre](args, kwargs)

    (thread_id, result) = api_calls.dispatch(func_name, *args, **kwargs)

    if func_name_post in g:
        result = g[func_name_post](result)

    return (os.getpid(), result)
def _dispatch(func_name, *args, **kwargs):
    return api_calls.dispatch(func_name, *args, **kwargs)