Style fixes (flake8).

main
Vincent Driessen 13 years ago
parent 10c48e1dbd
commit 6266f68310

@ -4,10 +4,11 @@ from .queue import Queue
from .worker import Worker from .worker import Worker
from .version import VERSION from .version import VERSION
def use_redis(redis=None): def use_redis(redis=None):
"""Pushes the given Redis connection (a redis.Redis instance) onto the """Pushes the given Redis connection (a redis.Redis instance) onto the
connection stack. This is merely a helper function to easily start using RQ connection stack. This is merely a helper function to easily start
without having to know or understand the RQ connection stack. using RQ without having to know or understand the RQ connection stack.
When given None as an argument, a (default) Redis connection to When given None as an argument, a (default) Redis connection to
redis://localhost:6379 is set up. redis://localhost:6379 is set up.

@ -73,7 +73,7 @@ class Job(object):
# Data access # Data access
def get_id(self): def get_id(self): # noqa
"""The job ID for this job instance. Generates an ID lazily the """The job ID for this job instance. Generates an ID lazily the
first time the ID is requested. first time the ID is requested.
""" """
@ -93,27 +93,28 @@ class Job(object):
return 'rq:job:%s' % (self.id,) return 'rq:job:%s' % (self.id,)
@property @property # noqa
def job_tuple(self): def job_tuple(self):
"""Returns the job tuple that encodes the actual function call that this job represents.""" """Returns the job tuple that encodes the actual function call that
this job represents."""
return (self.func, self.args, self.kwargs) return (self.func, self.args, self.kwargs)
@property @property
def return_value(self): def return_value(self):
"""Returns the return value of the job. """Returns the return value of the job.
Initially, right after enqueueing a job, the return value will be None. Initially, right after enqueueing a job, the return value will be
But when the job has been executed, and had a return value or exception, None. But when the job has been executed, and had a return value or
this will return that value or exception. exception, this will return that value or exception.
Note that, when the job has no return value (i.e. returns None), the Note that, when the job has no return value (i.e. returns None), the
ReadOnlyJob object is useless, as the result won't be written back to ReadOnlyJob object is useless, as the result won't be written back to
Redis. Redis.
Also note that you cannot draw the conclusion that a job has _not_ been Also note that you cannot draw the conclusion that a job has _not_
executed when its return value is None, since return values written back been executed when its return value is None, since return values
to Redis will expire after a given amount of time (500 seconds by written back to Redis will expire after a given amount of time (500
default). seconds by default).
""" """
if self._cached_result is None: if self._cached_result is None:
rv = conn.hget(self.key, 'result') rv = conn.hget(self.key, 'result')
@ -124,7 +125,7 @@ class Job(object):
# Persistence # Persistence
def refresh(self): def refresh(self): # noqa
"""Overwrite the current instance's properties with the values in the """Overwrite the current instance's properties with the values in the
corresponding Redis key. corresponding Redis key.
@ -180,14 +181,14 @@ class Job(object):
# Job execution # Job execution
def perform(self): def perform(self): # noqa
"""Invokes the job function with the job arguments. """Invokes the job function with the job arguments.
""" """
return self.func(*self.args, **self.kwargs) return self.func(*self.args, **self.kwargs)
# Representation # Representation
def get_call_string(self): def get_call_string(self): # noqa
"""Returns a string representation of the call, formatted as a regular """Returns a string representation of the call, formatted as a regular
Python function invocation statement. Python function invocation statement.
""" """
@ -204,9 +205,8 @@ class Job(object):
# Job equality # Job equality
def __eq__(self, other): def __eq__(self, other): # noqa
return self.id == other.id return self.id == other.id
def __hash__(self): def __hash__(self):
return hash(self.id) return hash(self.id)

Loading…
Cancel
Save