Add means of specifying the job function using strings.

main
Vincent Driessen 13 years ago
parent 3a8f30a53e
commit a032896453

@ -59,8 +59,10 @@ class Job(object):
if inspect.ismethod(func):
job._instance = func.im_self
job._func_name = func.__name__
else:
elif inspect.isfunction(func):
job._func_name = '%s.%s' % (func.__module__, func.__name__)
else: # we expect a string
job._func_name = func
job._args = args
job._kwargs = kwargs
job.description = job.get_call_string()

@ -112,12 +112,13 @@ class Queue(object):
it.
Expects the function to call, along with the arguments and keyword
arguments.
arguments. May be a fully qualified string of the function instance,
in which case the function must be meaningful to the worker.
The special keyword `timeout` is reserved for `enqueue()` itself and
it won't be passed to the actual job function.
"""
if f.__module__ == '__main__':
if not isinstance(f, basestring) and f.__module__ == '__main__':
raise ValueError(
'Functions from the __main__ module cannot be processed '
'by workers.')

Loading…
Cancel
Save