diff --git a/rq/compat/connections.py b/rq/compat/connections.py index 70c0bc6..7d8798b 100644 --- a/rq/compat/connections.py +++ b/rq/compat/connections.py @@ -21,11 +21,18 @@ def fix_return_type(func): PATCHED_METHODS = ['_setex', '_lrem', '_zadd', '_pipeline', '_ttl'] +def _hset(self, key, field_name, value, pipeline=None): + connection = pipeline if pipeline is not None else self + connection.hset(key, field_name, value) + + def patch_connection(connection): # Don't patch already patches objects if all([hasattr(connection, attr) for attr in PATCHED_METHODS]): return connection + connection._hset = partial(_hset, connection) + if isinstance(connection, Redis): connection._setex = partial(StrictRedis.setex, connection) connection._lrem = partial(StrictRedis.lrem, connection) diff --git a/rq/job.py b/rq/job.py index a9c5cc5..b73e3bd 100644 --- a/rq/job.py +++ b/rq/job.py @@ -152,7 +152,7 @@ class Job(object): def set_status(self, status, pipeline=None): self._status = status - self.hset_value('status', self._status, pipeline) + self.connection._hset(self.key, 'status', self._status, pipeline) def _set_status(self, status): warnings.warn( @@ -165,11 +165,7 @@ class Job(object): def set_started_at_now(self, pipeline=None): now_fmt = utcformat(utcnow()) - self.hset_value('started_at', now_fmt, pipeline) - - def hset_value(self, key, value, pipeline=None): - connection = pipeline if pipeline is not None else self.connection - connection.hset(self.key, key, value) + self.connection._hset(self.key, 'started_at', now_fmt, pipeline) @property def is_finished(self):