diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index e702a6b7..dcb1fb99 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -2,7 +2,9 @@ name: Test on: push: - branches: [ master ] + branches: + - master + - '**' pull_request: branches: [ master ] @@ -33,7 +35,7 @@ jobs: timeout-minutes: 10 strategy: matrix: - python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] + python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"] redis-version: [4, 5, 6, 7] redis-py-version: [3.5.0] @@ -64,4 +66,4 @@ jobs: uses: codecov/codecov-action@v4 with: file: ./coverage.xml - fail_ci_if_error: false + fail_ci_if_error: false \ No newline at end of file diff --git a/CHANGES.md b/CHANGES.md index 4db03e9e..e2ea1cea 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,15 +1,23 @@ ### RQ 2.0 (unreleased) -* Dropped support for Python 3.6 -* Dropped support for Redis server < 4 -* Support for multiple job executions. A job can now properly manage multiple executions running simultaneously, allowing future support for long running scheduled jobs. -* [DEPRECATED] `RoundRobinWorker` and `RandomWorker` are deprecated. Use `--dequeue-strategy ` instead. -#### Breaking Changes +New Features: +* Support for multiple job executions. A job can now properly manage multiple executions running simultaneously, allowing future support for long running scheduled jobs. + +Breaking Changes: +* Dropped support for Redis server < 4 +* `RoundRobinWorker` and `RandomWorker` are deprecated. Use `--dequeue-strategy ` instead. * `Job.__init__` requires both `id` and `connection` to be passed in. * `Job.exists()` requires `connection` argument to be passed in. * `Queue.all()` requires `connection` argument. * `@job` decorator now requires `connection` argument. +### RQ 1.16 (2024-02-24) +* Added a way for jobs to wait for latest result `job.latest_result(timeout=60)`. Thanks @ajnisbet! +* Fixed an issue where `stopped_callback` is not respected when job is enqueued via `enqueue_many()`. Thanks @eswolinsky3241! +* `worker-pool` no longer ignores `--quiet`. Thanks @Mindiell! +* Added compatibility with AWS Serverless Redis. Thanks @peter-gy! +* `worker-pool` now starts with scheduler. Thanks @chromium7! + ### RQ 1.15.1 (2023-06-20) * Fixed a bug that may cause a crash when cleaning intermediate queue. Thanks @selwin! * Fixed a bug that may cause canceled jobs to still run dependent jobs. Thanks @fredsod! diff --git a/docs/docs/results.md b/docs/docs/results.md index 2a2c6d46..80741fe8 100644 --- a/docs/docs/results.md +++ b/docs/docs/results.md @@ -157,9 +157,10 @@ for result in job.results(): print(result.created_at, result.type) ``` +_New in version 1.16.0._ To block until a result arrives, you can pass a timeout in seconds to `job.latest_result()`. If any results already exist, the latest result is returned immediately. If the timeout is reached without a result arriving, a `None` object is returned. ```python job = queue.enqueue(sleep_for_10_seconds) -result = job.fetch_latest(timeout=60) # Will hang for about 10 seconds. +result = job.latest_result(timeout=60) # Will hang for about 10 seconds. ``` \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 2df4f005..265bf96b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,6 +34,7 @@ classifiers = [ "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "Topic :: Internet", "Topic :: Scientific/Engineering", "Topic :: Software Development :: Libraries :: Python Modules", diff --git a/rq/contrib/legacy.py b/rq/contrib/legacy.py new file mode 100644 index 00000000..9362d697 --- /dev/null +++ b/rq/contrib/legacy.py @@ -0,0 +1,23 @@ +import logging + +from rq import Worker, get_current_connection + +logger = logging.getLogger(__name__) + + +def cleanup_ghosts(conn=None, worker_class=Worker): + """ + RQ versions < 0.3.6 suffered from a race condition where workers, when + abruptly terminated, did not have a chance to clean up their worker + registration, leading to reports of ghosted workers in `rqinfo`. Since + 0.3.6, new worker registrations automatically expire, and the worker will + make sure to refresh the registrations as long as it's alive. + + This function will clean up any of such legacy ghosted workers. + """ + conn = conn if conn else get_current_connection() + for worker in worker_class.all(connection=conn): + if conn.ttl(worker.key) == -1: + ttl = worker.worker_ttl + conn.expire(worker.key, ttl) + logger.info('Marked ghosted worker {0} to expire in {1} seconds.'.format(worker.name, ttl)) diff --git a/rq/version.py b/rq/version.py index 3e4fa760..a51469e2 100644 --- a/rq/version.py +++ b/rq/version.py @@ -1 +1 @@ -VERSION = '1.15.1' +VERSION = '1.16.0'