Commit Graph

1792 Commits

Author SHA1 Message Date
Rob Hudson 0935f47213 Store project metadata in pyproject.toml (PEP 621) (#1952) 2024-02-24 10:07:56 +07:00
Ethan Wolinsky efd4bd82d7 Delete maintenance lock after registries cleaned (#2024)
* Delete maintenance lock after registries cleaned

* Fix test to assert that lock is released

* Remove deprecated test case
2024-02-24 09:54:47 +07:00
Ethan Wolinsky 1e6953b534 Fix bug with stopped callback in enqueue_many (#1954)
* Fix bug with stopped callback in enqueue_many

* Add test for callbacks enqueued using enqueue_many
2024-02-24 09:51:20 +07:00
Christofer Saputra 49f12451ba Set workerpool with_scheduler defaults to True (#2027)
* Set workerpool with_scheduler defaults to True

* Add delay before sending shutdown command

* Black format

* Delay a bit longer for test
2024-02-24 09:50:26 +07:00
Péter Gyarmati 2440db31f1 fix: cast redis server version from `float` to `str` (#2025)
Currently, with Redis engine 7.1, and `redis` client 5.0.1 trying to enqueue a new job yields

```text
AttributeError: 'float' object has no attribute 'split'
```

This is caused by the fact that `redis_conn.info("server")["redis_version"]` returns a `float`, not a `str`.
2024-02-24 09:50:12 +07:00
Simó Albert i Beltran 7349032bbf fix_cleanup_ghosts_by_using_configured_worker_class (#1988)
Signed-off-by: Simó Albert i Beltran <sim6@bona.gent>
2024-02-24 09:49:50 +07:00
Andrew Nisbet 87da060648 Add result blocking (#1939)
* Add result blocking

* Dev tidyup

* Skip XREAD test on old redis versions

* Lint

* Clarify that the latest result is returned.

* Fix job test ordering

* Remove test latency hack

* Readability improvements
2024-02-24 09:48:28 +07:00
Selwin Ong f15cad4501 Bump version to 1.15.1 2023-06-20 06:28:45 +07:00
Fred Söderberg d4159ee804
Do not run dependent jobs when parent or job is canceled (#1947) 2023-06-18 10:25:12 +07:00
Simon Blanchard a26f6244e3
add lint target in Makefile (#1940)
* add lint target in Makefile

add black and ruff to dev reqs

* remove black and ruff from 3.6 reqs as ruff is not compatible with 3.6

* remove black and ruff - seems to be causing tests to fail
2023-06-13 12:01:24 +07:00
Selwin Ong 6cfb5a6012
Don't call handle_job_failure if job is no longer present (#1946) 2023-06-13 08:34:25 +07:00
Rob Hudson 10230ff040
Fix a few concatenated strings that don't have to be (#1941) 2023-06-12 07:47:31 +07:00
Simon Blanchard c2bec19b09
pass exc_string as an argument to log (#1934)
* pass exc_string as an argument to log

* fix test of exception log by accessing right arg

* fix black "error"
2023-06-08 15:55:58 +07:00
Dominik Aumayr 2faba2cea9
Add __all__ to please mypy (#1928)
* Add __all__ to please mypy

mypy complains with "implicit reexport disabled" when importing directly from the main `rq` package, eg.

from rq import Worker

Without adding an `__all__` to `__init__.py`, mypy would expect it this way:

from rq.worker import Worker

This PR does add the `__all__` to `__init__.py` to please mypy.

* Lint
2023-06-07 10:11:15 +07:00
Selwin Ong c6b0409fca Updated changelog. 2023-05-27 09:26:09 +07:00
Rishabh Ranjan a53966c918
callback func as string (#1905)
* callback func as string

* add tests for string callbacks; update documentation and type annotations

* lint

* concise test for string callback

* add string callbacks to existing tests

* remove string callback testcase; extend existing testcases
2023-05-26 08:40:56 +07:00
Rob Hudson f158fe7ba1
Update log string for better output when multiple queues (#1925) 2023-05-25 09:08:17 +07:00
dependabot[bot] 47b384d412
Bump actions/setup-python from 4.6.0 to 4.6.1 (#1923)
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4.6.0 to 4.6.1.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/v4.6.0...v4.6.1)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-05-25 06:27:05 +07:00
Ethan Wolinsky 6fdadaabe4
Document_stopped_jobs and dependents for enqueue_many (#1922)
* Add documentation for on_stopped callback

* Update dependent jobs documentation

Starting in version 1.15.0, enqueue_many supports dependent jobs.

* Add stopped callback usage example

* Update callback docstring

* Fix arg type

* Remove trailing whitespace
2023-05-25 06:26:42 +07:00
Selwin Ong 4011186c35 Bump version to v1.15 2023-05-24 06:35:03 +07:00
Cyril Chapellier 933860ee8c
fix: linting error (#1920) 2023-05-24 06:06:46 +07:00
Cyril Chapellier 421fd98a9c
[Tests] Only run SSL tests in Docker (#1918)
* Only run SSL tests in docker workflow

* Rename workflow
2023-05-23 14:24:55 +07:00
Cyril Chapellier 0b5a90adac
Fix as_text in certain conditions (#1917) 2023-05-22 09:07:30 +07:00
Ethan Wolinsky 192fbc9c50
Add support for a callback on stopped jobs (#1909)
* Add support for a callback on stopped jobs

This function will run when an active job is stopped using the
send_stopped_job_command_function

* Remove testing async job with stopped callback

* Remove stopped job test from simpleworker case.

I can't stop the job from the test until the work() method returns, at which point the
job can't be stopped.

* Improve coverage

* Add test for stopped callback execution

* Move stopped callback check out of execution func

* Use SimpleWorker for stopped callback test

* Call stopped callback directly in main proc

* Remove unused imports

* Fix import order

* Fix import order

* Fix death penalty class arg

* Fix worker instance init

Sorry these commits are so lazy
2023-05-22 09:06:02 +07:00
Ethan Wolinsky b756cf82bd
Add support for dependent jobs in enqueue_many (#1897)
* Add support for dependent jobs in enqueue_many

* Add module to register dependencies for multiple jobs

The get_ready_jobs function will process dependencies for an array of
jobs passed in. If any jobs' dependencies are already met, those jobs
are returned so they can be enqueued.

* Add check for jobs without dependencies

* Remove extra colon in dependencies key

This seems like a bug, but if I'm mistaken please let me know.

* Add bulk deferred jobs to Redis

Need to call queue.enqueue_job to create the job hash in redis. Since all of
these jobs are deferred, they won't be added to the queue and processed
by a worker.

* Revert "Remove extra colon in dependencies key"

This reverts commit 5ebf7a3500.

* Enqueue jobs without dependencies separately

Any jobs without dependencies will be enqueued before handling

* Fix enqueue_many return value

* Rename ready_jobs function

* Fix enqueue_many return value

* Instantiate job category arrays before if statement

* Execute pipe to enqueue jobs with met dependencies

* Add tests for enqueue_many with dependencies

* Change dependency sorting function name

* Use common kwargs dict to create jobs

* Remove redundant tests for dependent jobs

* Alphebetize imports

* Test job with met dependencies using enqueue_many

* Fix typo

* Format with black

* Sort imports
2023-05-21 09:41:07 +07:00
Selwin Ong ffacdcb675
Update tox.ini to not run linters (#1916) 2023-05-19 08:17:49 +07:00
Selwin Ong 37ddcb51cd
Reliable queue (#1911)
* Use lmove() when working on a single queue

* Skip reliable queue tests if Redis server doesn't support LMOVE

* Better test coverage

* job.origin should be string

* Added test for job that gets orphaned if worker.execute_job() fails

* Fix job tests

* worker.run_maintenance_tasks() now cleans intermediate queues

* Fixed import ordering

* No need to run slow tests and flake8 on SSL tests

* Minor typing fixes

* Fixed linting
2023-05-18 18:01:01 +07:00
juur 107221fd9e
Update cli.py to support custom loggers (#1906)
* Update cli.py to support custom loggers

Allows a config.py file (via rq worker --config) to support things like this for logfmt logging:

DICT_CONFIG = {
        "version": 1,
        "formatters": {"logfmt": {
            "()": "logfmter.Logfmter",
            "keys": ["level","when","pid"],
            "mapping": {"level":"levelname","when":"asctime","pid":"process"},
            "datefmt": "%Y-%m-%dT%H:%M:%S%z"
            }},
        "handlers": {"console": {"class": "logging.StreamHandler","formatter": "logfmt" }},
        "loggers": {
            "root": {"handlers":["console"], "level": "INFO"},
            "rq":   {"handlers":["console"], "level": "INFO", "propagate": False},
            }
        }

* added simple test and documentation for DICT_CONFIG

* further attempt to get testing right for dictConfig

* move import to correct location

* fix

* remove meaningless options.get() usage

* linting checks and added missing test config file
2023-05-18 07:04:57 +07:00
xzander bdbc9a4f9c
Scheduler should release and heartbeat only acquired locks (#1914)
* Scheduler should release and heartbeat only acquired locks.

* Added tests for heartbeat and release only acquired locks.

* Changed test description to correct one.
2023-05-18 06:59:51 +07:00
Rob Hudson ea063edf0a
Update linting configuration (#1915)
* Update linting configuration

This removes flake8 in favor of ruff, which also provides isort support, and
updates all files to be black, isort, and ruff compliant. This also adds black
and ruff checks to the tox and Github linting workflow.

* Tweak the code coverage config and calls
2023-05-17 23:19:14 +07:00
dependabot[bot] bbfeb8c8ed
Bump docker/build-push-action from 2 to 4 (#1913)
Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 2 to 4.
- [Release notes](https://github.com/docker/build-push-action/releases)
- [Commits](https://github.com/docker/build-push-action/compare/v2...v4)

---
updated-dependencies:
- dependency-name: docker/build-push-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-05-16 06:03:26 +07:00
Tom Hamilton Stubber edc93c380f
Stop calling deprecated function (#1908) 2023-05-14 07:48:36 +07:00
Cyril Chapellier 84833b9c5f
[Chore] Fix test suite (#1895)
* fix: tests suite

* chore: add SSL tests
2023-05-13 21:49:59 +07:00
Selwin Ong 46d0056a69 Bump version to 1.14.1 2023-05-05 21:00:49 +07:00
Cyril Chapellier a228b4838c
[Hotfix] Fix SSL connection for scheduler (#1894)
* fix: ssl

* fix: reinstate a test for parse_connection
2023-05-05 14:25:20 +07:00
gabriels1234 07fef85dd2
Catch serializer TypeError Exception (#1872)
* Catch serializer TypeError Exception

* Add test for unserializable job.meta
2023-05-03 14:27:31 +07:00
Selwin Ong af2dfb1446 Deleted redundant requirements from dev-requirements.txt 2023-05-03 06:52:56 +07:00
Selwin Ong 5787e8f4a0
Coverage fixes (#1890)
* Don't fail CI if codecov fails

* Remove codecov from dev-requirements.txt

* Pin packaging dependency to 21.3

* Pin coverage to 6.5.0

* Pin coverage to 6.2

* Downgrade packaging

* Drop Python 3.6 from test matrix

* Reenable Python 3.6 in tests

* Downgrade coverage req

* Make a different dev-requirements file for Python 3.6

* Moved dev-requirements-36 to root dir
2023-05-03 05:46:10 +07:00
Selwin Ong 5f883c6e1c Merge branch 'master' of github.com:rq/rq 2023-05-01 17:54:33 +07:00
Selwin Ong 5e70e523d3 Bump version to 0.14.0 2023-05-01 17:54:20 +07:00
Selwin Ong 64cb1a27b9
Worker pool (#1874)
* First stab at implementating worker pool

* Use process.is_alive() to check whether a process is still live

* Handle shutdown signal

* Check worker loop done

* First working version of `WorkerPool`.

* Added test for check_workers()

* Added test for pool.start()

* Better shutdown process

* Comment out test_start() to see if it fixes CI

* Make tests pass

* Make CI pass

* Comment out some tests

* Comment out more tests

* Re-enable a test

* Re-enable another test

* Uncomment check_workers test

* Added run_worker test

* Minor modification to dead worker detection

* More test cases

* Better process name for workers

* Added back pool.stop_workers() when signal is received

* Cleaned up cli.py

* WIP on worker-pool command

* Fix test

* Test that worker pool ignores consecutive shutdown signals

* Added test for worker-pool CLI command.

* Added timeout to CI jobs

* Fix worker pool test

* Comment out test_scheduler.py

* Fixed worker-pool in burst mode

* Increase test coverage

* Exclude tests directory from coverage.py

* Improve test coverage

* Renamed `Pool(num_workers=2) to `Pool(size=2)`

* Revert "Renamed `Pool(num_workers=2) to `Pool(size=2)`"

This reverts commit a1306f89ad.

* Renamed Pool to WorkerPool

* Added a new TestCase that doesn't use LocalStack

* Added job_class, worker_class and serializer arguments to WorkerPool

* Use parse_connection() in WorkerPool.__init__

* Added CLI arguments for worker-pool

* Minor WorkerPool and test fixes

* Fixed failing CLI test

* Document WorkerPool
2023-05-01 12:44:32 +07:00
Selwin Ong 8a9daecaf2 Added changelog 2023-05-01 12:43:45 +07:00
Cyril Chapellier 08cb311c55
[Results] Allow unserializable return values (#1888)
* fix: allow unserializable return values

* fix: review comments
2023-05-01 11:20:40 +07:00
Selwin Ong 36f5c88ca2
Added BaseWorker class (#1887)
* Added BaseWorker class

* Moved logging related functions to logutils

* Remove uneeded colorize function

* Updated worker.get_current_job_id() to not fail when job ID is None

* job.restore() shouldn't crash if  is not present

* Fix various as_text() related crashes
2023-04-26 09:16:37 +07:00
Rob Hudson 4073aa3642
Update `push_job_id` debug string when using pipelines (#1886) 2023-04-26 05:51:58 +07:00
Selwin Ong 77e926c424
Added parse_connection function (#1884)
* Added parse_connection function

* feat: allow custom connection pool class (#1885)

* Added test for SSL

---------

Co-authored-by: Cyril Chapellier <tchapi@users.noreply.github.com>
2023-04-25 19:38:44 +07:00
Selwin Ong 95983cfcac Exclude tests directory from coverage.py 2023-04-25 09:43:36 +07:00
Selwin Ong 60bed7d58c
Exclude tests dir from coverage.py (#1883) 2023-04-23 16:48:04 +07:00
nhairs 67b2c982f9
Add py.typed for PEP561 compliance (#1882) 2023-04-23 16:15:42 +07:00
dependabot[bot] 74746cc390
Bump actions/setup-python from 4.5.0 to 4.6.0 (#1880)
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4.5.0 to 4.6.0.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/v4.5.0...v4.6.0)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-04-23 16:15:11 +07:00