Skip to content

Commit

Permalink
[IMP] queue_job: Cleaned TODO tags
Browse files Browse the repository at this point in the history
  • Loading branch information
QuocDuong1306 committed Sep 25, 2024
1 parent 08e184e commit cfcceeb
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 58 deletions.
11 changes: 1 addition & 10 deletions queue_job/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from odoo.service.model import PG_CONCURRENCY_ERRORS_TO_RETRY

from ..delay import chain, group
from ..exception import FailedJobError, NothingToDoJob, RetryableJobError
from ..exception import FailedJobError, RetryableJobError
from ..job import ENQUEUED, Job

_logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -114,15 +114,6 @@ def retry_postpone(job, message, seconds=None):
_logger.debug("%s OperationalError, postponed", job)
raise RetryableJobError(err.pgerror, seconds=PG_RETRY) from err

except NothingToDoJob as err:
if str(err):
msg = str(err)
else:
msg = _("Job interrupted and set to Done: nothing to do.")
job.set_done(msg)
job.store()
env.cr.commit()

except RetryableJobError as err:
# delay the job later, requeue
retry_postpone(job, str(err), seconds=err.seconds)
Expand Down
5 changes: 0 additions & 5 deletions queue_job/exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,5 @@ def __init__(self, msg, seconds=None, ignore_retry=False):
self.ignore_retry = ignore_retry


# TODO: remove support of NothingToDo: too dangerous
class NothingToDoJob(JobError):
"""The Job has nothing to do."""


class ChannelNotFound(BaseQueueJobError):
"""A channel could not be found"""
19 changes: 0 additions & 19 deletions queue_job/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,6 @@
_logger = logging.getLogger(__name__)


# TODO remove in 15.0 or 16.0, used to keep compatibility as the
# class has been moved in 'delay'.
def DelayableRecordset(*args, **kwargs):
# prevent circular import
from .delay import DelayableRecordset as dr

_logger.debug(
"DelayableRecordset moved from the queue_job.job"
" to the queue_job.delay python module"
)
return dr(*args, **kwargs)


def identity_exact(job_):
"""Identity function using the model, method and all arguments as key
Expand Down Expand Up @@ -371,12 +358,6 @@ def _enqueue_job(self):
)
return self

@staticmethod
def db_record_from_uuid(env, job_uuid):
# TODO remove in 15.0 or 16.0
_logger.debug("deprecated, use 'db_records_from_uuids")
return Job.db_records_from_uuids(env, [job_uuid])

@staticmethod
def db_records_from_uuids(env, job_uuids):
model = env["queue.job"].sudo()
Expand Down
6 changes: 1 addition & 5 deletions queue_job/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

from odoo import api, models

from ..delay import Delayable
from ..job import DelayableRecordset
from ..delay import Delayable, DelayableRecordset
from ..utils import must_run_without_delay


Expand Down Expand Up @@ -169,9 +168,6 @@ def _patch_job_auto_delay(self, method_name, context_key=None):
method named after the name of the method suffixed by ``_job_options``
which takes the same parameters as the initial method.
It is still possible to force synchronous execution of the method by
setting a key ``_job_force_sync`` to True in the environment context.
Example patching the "foo" method to be automatically delayed as job
(the job options method is optional):
Expand Down
19 changes: 0 additions & 19 deletions queue_job/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,10 @@ def must_run_without_delay(env):
:param env: `odoo.api.Environment` instance
"""
# TODO: drop in v17
if os.getenv("TEST_QUEUE_JOB_NO_DELAY"):
_logger.warning(
"`TEST_QUEUE_JOB_NO_DELAY` env var found. NO JOB scheduled. "
"Note that this key is deprecated: please use `QUEUE_JOB__NO_DELAY`"
)
return True

if os.getenv("QUEUE_JOB__NO_DELAY"):
_logger.warning("`QUEUE_JOB__NO_DELAY` env var found. NO JOB scheduled.")
return True

# TODO: drop in v17
deprecated_keys = ("_job_force_sync", "test_queue_job_no_delay")
for key in deprecated_keys:
if env.context.get(key):
_logger.warning(
"`%s` ctx key found. NO JOB scheduled. "
"Note that this key is deprecated: please use `queue_job__no_delay`",
key,
)
return True

if env.context.get("queue_job__no_delay"):
_logger.warning("`queue_job__no_delay` ctx key found. NO JOB scheduled.")
return True

0 comments on commit cfcceeb

Please sign in to comment.