示例#1
0
def execute_remote(fun, *args, **kwargs):
    """Execute arbitrary function/object remotely.

    :param fun: A callable function or object.
    :param \*args: Positional arguments to apply to the function.
    :param \*\*kwargs: Keyword arguments to apply to the function.

    The object must be picklable, so you can't use lambdas or functions
    defined in the REPL (the objects must have an associated module).

    :returns: class:`celery.result.AsyncResult`.

    """
    return ExecuteRemoteTask.delay(pickle.dumps(fun), args, kwargs)
示例#2
0
 def test_execute_remote(self):
     self.assertEqual(ExecuteRemoteTask.apply(
                         args=[pickle.dumps(some_func), [10], {}]).get(),
                       100)