Merge branch 'andrewsg-warnings'

main
Vincent Driessen 11 years ago
commit d37f49f643

@ -4,6 +4,7 @@ from __future__ import (absolute_import, division, print_function,
import inspect import inspect
from uuid import uuid4 from uuid import uuid4
import warnings
from rq.compat import as_text, decode_redis_hash, string_types, text_type from rq.compat import as_text, decode_redis_hash, string_types, text_type
@ -131,8 +132,9 @@ class Job(object):
return self._status return self._status
def _get_status(self): def _get_status(self):
raise DeprecationWarning( warnings.warn(
"job.status is deprecated. Use job.get_status() instead" "job.status is deprecated. Use job.get_status() instead",
DeprecationWarning
) )
return self.get_status() return self.get_status()
@ -141,8 +143,9 @@ class Job(object):
self.connection.hset(self.key, 'status', self._status) self.connection.hset(self.key, 'status', self._status)
def _set_status(self, status): def _set_status(self, status):
raise DeprecationWarning( warnings.warn(
"job.status is deprecated. Use job.set_status() instead" "job.status is deprecated. Use job.set_status() instead",
DeprecationWarning
) )
self.set_status(status) self.set_status(status)

@ -11,6 +11,7 @@ import socket
import sys import sys
import time import time
import traceback import traceback
import warnings
from rq.compat import as_text, string_types, text_type from rq.compat import as_text, string_types, text_type
@ -240,8 +241,9 @@ class Worker(object):
def _set_state(self, state): def _set_state(self, state):
"""Raise a DeprecationWarning if ``worker.state = X`` is used""" """Raise a DeprecationWarning if ``worker.state = X`` is used"""
raise DeprecationWarning( warnings.warn(
"worker.state is deprecated, use worker.set_state() instead." "worker.state is deprecated, use worker.set_state() instead.",
DeprecationWarning
) )
self.set_state(state) self.set_state(state)
@ -250,8 +252,9 @@ class Worker(object):
def _get_state(self): def _get_state(self):
"""Raise a DeprecationWarning if ``worker.state == X`` is used""" """Raise a DeprecationWarning if ``worker.state == X`` is used"""
raise DeprecationWarning( warnings.warn(
"worker.state is deprecated, use worker.get_state() instead." "worker.state is deprecated, use worker.get_state() instead.",
DeprecationWarning
) )
return self.get_state() return self.get_state()

Loading…
Cancel
Save