diff --git a/rq/job.py b/rq/job.py index 79239b3..0718e97 100644 --- a/rq/job.py +++ b/rq/job.py @@ -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() diff --git a/rq/queue.py b/rq/queue.py index a7e5dfe..bc56ce7 100644 --- a/rq/queue.py +++ b/rq/queue.py @@ -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.')