From 86467dcf03a269634e8db18e3300c790a53e657d Mon Sep 17 00:00:00 2001 From: GDay <1939656+GDay@users.noreply.github.com> Date: Fri, 31 Mar 2023 02:22:38 +0200 Subject: [PATCH] Revert "Merge pull request #15 from django-q2/error-on-timeout" This reverts commit d97dca5bcb7cc118ec754cbaf6c8bee7cd4f43b4, reversing changes made to 01cb652071f2075961f65c2bae6aef74df88dce7. --- django_q/cluster.py | 32 -------------------------------- django_q/conf.py | 3 --- docs/configure.rst | 5 ----- pyproject.toml | 4 ---- 4 files changed, 44 deletions(-) diff --git a/django_q/cluster.py b/django_q/cluster.py index 301eea0..13d7a2f 100644 --- a/django_q/cluster.py +++ b/django_q/cluster.py @@ -458,29 +458,6 @@ def monitor(result_queue: Queue, broker: Broker = None): logger.info(_("%(name)s stopped monitoring results") % {"name": proc_name}) -def _check_task_timed_out(key, task: dict): - result = None - broker = get_broker() - cache = broker.cache - working_set = cache.get(key) or set() - if task["id"] in working_set: - # the previous worker has timedout and wasn't given chance to clear - raise Exception(f"Task Timed-out: {task}.") - else: - working_set.add(task['id']) - cache.set(key, working_set, timeout=Conf.RETRY * 3) - return result - - -def _clear_task_timeout_cache(key, task): - broker = get_broker() - cache = broker.cache - working_set = cache.get(key) or set() - if task["id"] in working_set: - working_set.remove(task['id']) - cache.set(key, working_set, timeout=Conf.RETRY * 3) - - def worker( task_queue: Queue, result_queue: Queue, timer: Value, timeout: int = Conf.TIMEOUT ): @@ -502,8 +479,6 @@ def worker( task_count = 0 if timeout is None: timeout = -1 - - working_tasks_key = "DJANGO-Q-WORKING-TASKS" # Start reading the task queue for task in iter(task_queue.get, "STOP"): result = None @@ -543,11 +518,7 @@ def worker( pre_execute.send(sender="django_q", func=f, task=task) # execute the payload timer.value = timer_value # Busy - - try: - if Conf.FAIL_ON_TIMEOUT: - _check_task_timed_out(working_tasks_key, task) if f is None: # raise a meaningfull error if task["func"] is not a valid function raise ValueError(f"Function {task['func']} is not defined") @@ -559,9 +530,6 @@ def worker( error_reporter.report() if task.get("sync", False): raise - if Conf.FAIL_ON_TIMEOUT: - _clear_task_timeout_cache(working_tasks_key, task) - with timer.get_lock(): # Process result task["result"] = result[0] diff --git a/django_q/conf.py b/django_q/conf.py index b60f055..fb556ba 100644 --- a/django_q/conf.py +++ b/django_q/conf.py @@ -133,9 +133,6 @@ class Conf: # Number of seconds to wait for a worker to finish. TIMEOUT = conf.get("timeout", None) - # Whether to fail the task when it times-out. - FAIL_ON_TIMEOUT = conf.get("fail_on_timeout", False) - # Whether to acknowledge unsuccessful tasks. # This causes failed tasks to be considered delivered, thereby removing them from # the task queue. Defaults to False. diff --git a/docs/configure.rst b/docs/configure.rst index f3861e2..3b96df8 100644 --- a/docs/configure.rst +++ b/docs/configure.rst @@ -70,11 +70,6 @@ Set this to something that makes sense for your project. Can be overridden for i See :ref:`retry` for details how to set values for timeout and retry. -fail_on_timeout -~~~~~~~~~~~~~~~ - -When set to ``True``, timeouts will result in error. Defaults to ``False``. - .. _time_zone: time_zone diff --git a/pyproject.toml b/pyproject.toml index d060c19..e375c7d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -80,7 +80,3 @@ sentry = ["django-q-sentry"] [tool.isort] profile = "black" multi_line_output = 3 - -[build-system] -requires = ["poetry-core>=1.0.8"] -build-backend = "poetry.core.masonry.api"