Commit Graph

1905 Commits

Author SHA1 Message Date
dependabot[bot] 01635dc809
Bump actions/setup-python from 4.1.0 to 4.2.0 (#1687)
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4.1.0 to 4.2.0.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/v4.1.0...v4.2.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>
2022-08-03 07:11:43 +07:00
Yang Yang 3f59a7e6e3
Support callbacks in enqueue_many (#1686)
The on_success and on_failure callbacks are currently supported in
Queue.enqueue but not Queue.enqueue_many, despite documentary indicating
the contrary.

This commit brings the bulk enqueuing API back into parity.

Fixes #1680
2022-08-03 06:09:24 +07:00
Selwin Ong 98c200d07a Bump version to 1.11.0 2022-07-31 17:00:37 +07:00
Selwin Ong c0bb0ba4e6 Merge branch 'master' of github.com:rq/rq 2022-07-31 16:55:14 +07:00
Selwin Ong d08cc72842
Added Redis 7 to test matrix (#1683)
* Updated changelog.

* Added Redis 7 and redis-py 4.3 to test matrix

* Addd Redis 7 to test matrix

* Addd Redis 7 to test matrix
2022-07-31 16:55:01 +07:00
Selwin Ong 08377698ab Updated changelog. 2022-07-31 15:56:59 +07:00
Selwin Ong bc5bb1fba2
Revert "Jobs that are run synchronously should always raise an exception" (#1682)
This reverts commit 0d21e714c3.
2022-07-31 15:53:18 +07:00
Selwin Ong 5b95725dc4
Dependency with failures (#1681)
* added Dependency class with allow_failures

* Requested changes

* Check type before setting `job.dependency_allow_fail` within `Job.create`

* Set `job.dependency_allow_fail` within `Job.create`

* Added test to ensure persistence of `dependency_allow_fail`

* Removed typing and allow mixed list of ints and Job objects

* Convert dependency_allow_fail boolean to integer during serialization to avoid redis DataError

* Updated `test_multiple_dependencies_are_accepted_and_persisted` test to include `Dependency` cases

* Adding placeholder test to test actual behavior of new `Dependency` usage in `depends_on`

* Updated `test_job_dependency` to include cases using `Dependency`

* Added dependency_allow_fail logic to `Job.restore`

* Renamed `dependency_allow_fail` to a simpler `allow_failure`

* Update docs to add section about the new `Dependency` class and use-case

* Updated `Job.dependencies_are_met` logic to take `FAILED` and `STOPPED` jobs into account when `allow_failure=True`

* Updated `test_job_dependency` test. Still failing with `Dependency` case.

* Fix `allow_failure` type coercion in `Job.restore`

* Re-arrange tests, so default `Dependency.allow_failure` is before explicit `allow_failure=True`

* Fixed Dependency, so it works correctly when allow_failure=True

* Attempt to execute pipeline prior to queueing a failed job's dependents. test_create_and_cancel_job_enqueue_dependents_in_registry test now passes.

* Added `Depedency` test utilizing multiple dependencies

* Removed irrelevant on_success and on_failure keyword arguments in example

* Replaced use of long_running_job

* Add test to verify `Dependency.jobs` contraints

* Suppress connection error in handle_job_failure

* test_dependencies have passed

* All tests pass if enqueue_dependents called without pipeline.watch()

* All tests now pass

* Removed print statements

* Cleanup Dependency implementation

* Renamed job.allow_failure to job.allow_dependency_failures

Co-authored-by: mattchan <mattchan@tencent.com>
Co-authored-by: Mike Hill <mhilluniversal@gmail.com>
2022-07-31 15:35:10 +07:00
Tim Gates d82af1469f
docs: Fix a few typos (#1679)
There are small typos in:
- docs/docs/exceptions.md
- docs/docs/jobs.md
- rq/queue.py
- tests/fixtures.py
- tests/test_job.py

Fixes:
- Should read `slightly` rather than `slighty`.
- Should read `requeuing` rather than `requeueing`.
- Should read `implementers` rather than `implementors`.
- Should read `definition` rather than `defition`.
- Should read `canceled` rather than `canceld`.

Signed-off-by: Tim Gates <tim.gates@iress.com>
2022-07-31 09:23:06 +07:00
Selwin Ong 145884fcd5
When stopped jobs are deleted, they should also be removed from FailedJobRegistry. (#1677) 2022-07-24 10:56:35 +07:00
dependabot[bot] 468eb00c13
Bump actions/setup-python from 3 to 4.1.0 (#1675)
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 3 to 4.1.0.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/v3...v4.1.0)

---
updated-dependencies:
- dependency-name: actions/setup-python
  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>
2022-07-24 08:18:09 +07:00
Hugo d5175c38da
Drop python2-specific syntax (#1674)
* Drop syntax required only for Python 2

* Drop python2-style super() calls

Co-authored-by: Selwin Ong <selwin.ong@gmail.com>
2022-07-24 08:17:07 +07:00
Hugo 61a4a1720b
Use unittest.mock instead of mock (#1673)
This module has been included in Python itself since 3.3.

Fixes: https://github.com/rq/rq/issues/1646
2022-07-24 07:12:40 +07:00
Selwin Ong 87bacb650e
Jobs that are run synchronously should always raise an exception (#1671) 2022-07-01 09:27:17 +07:00
Naveen aff877cfcf
chore: Enable codeql action (#1666)
This action runs GitHub's industry-leading semantic code analysis engine,
CodeQL, against a repository's source code to find security vulnerabilities.

https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/about-code-scanning-with-codeql

https://github.com/ossf/scorecard/blob/main/docs/checks.md#sast
Signed-off-by: naveen <172697+naveensrinivasan@users.noreply.github.com>
2022-05-30 13:19:22 +07:00
Pavel Levchuk aff862dd6a
Fix syntax error in docs example (#1664)
Adds a missing colon in function arguments
2022-05-30 13:18:25 +07:00
dependabot[bot] a69498e185
Bump actions/setup-python from 2 to 3 (#1658)
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 2 to 3.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/setup-python
  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>
2022-05-22 17:43:08 +07:00
Steve Kreitzer ecf0d06090
Support at_front requeue support (#1657)
Co-authored-by: Steve Kreitzer <skreitzer@cloudflare.com>
2022-05-22 12:56:14 +07:00
dependabot[bot] 48df759879
Bump codecov/codecov-action from 1 to 3 (#1660)
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 1 to 3.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/master/CHANGELOG.md)
- [Commits](https://github.com/codecov/codecov-action/compare/v1...v3)

---
updated-dependencies:
- dependency-name: codecov/codecov-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>
2022-05-22 12:55:05 +07:00
dependabot[bot] a2ada2d1ec
Bump supercharge/redis-github-action from 1.1.0 to 1.4.0 (#1661)
Bumps [supercharge/redis-github-action](https://github.com/supercharge/redis-github-action) from 1.1.0 to 1.4.0.
- [Release notes](https://github.com/supercharge/redis-github-action/releases)
- [Changelog](https://github.com/supercharge/redis-github-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/supercharge/redis-github-action/compare/1.1.0...1.4.0)

---
updated-dependencies:
- dependency-name: supercharge/redis-github-action
  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>
2022-05-22 12:54:49 +07:00
dependabot[bot] ae0611b967
Bump actions/upload-artifact from 2 to 3 (#1663)
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 2 to 3.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  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>
2022-05-22 12:54:33 +07:00
dependabot[bot] c503823ff8
Bump actions/download-artifact from 2 to 3 (#1662)
Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 2 to 3.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](https://github.com/actions/download-artifact/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  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>
2022-05-22 12:54:20 +07:00
dependabot[bot] 395fd1c51a
Bump actions/checkout from 2 to 3 (#1659)
Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 3.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/checkout
  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>
2022-05-22 12:53:59 +07:00
Naveen 4875db7a9c
chore: Included githubactions in the dependabot config (#1656)
This should help with keeping the GitHub actions updated on new releases. This will also help with keeping it secure.

Dependabot helps in keeping the supply chain secure https://docs.github.com/en/code-security/dependabot

GitHub actions up to date https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot

https://github.com/ossf/scorecard/blob/main/docs/checks.md#dependency-update-tool
Signed-off-by: naveensrinivasan <172697+naveensrinivasan@users.noreply.github.com>
2022-05-22 09:22:12 +07:00
Naveen adfb355abe
chore: Set permissions for GitHub actions (#1648)
Restrict the GitHub token permissions only to the required ones; this way, even if the attackers will succeed in compromising your workflow, they won’t be able to do much.

- Included permissions for the action. https://github.com/ossf/scorecard/blob/main/docs/checks.md#token-permissions

https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions

https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs

[Keeping your GitHub Actions and workflows secure Part 1: Preventing pwn requests](https://securitylab.github.com/research/github-actions-preventing-pwn-requests/)

Signed-off-by: naveen <172697+naveensrinivasan@users.noreply.github.com>
2022-05-16 15:25:31 +07:00
nevious 5eb2f0b9a4
added ssl support for sentinel connections (#1649)
Co-authored-by: Christian Schläppi <cschlaeppi@hosttech.ch>
2022-05-16 15:24:37 +07:00
urmikab f2a3e8d346
Update exceptions.md (#1655)
Added the import statement for Job (line 18)
2022-05-16 11:26:21 +07:00
Rajesh Khadka d2dcc2fb6b
fix typo (#1640) 2022-04-02 08:06:55 +07:00
Jannis Vajen 8877d0ff52
Update link to Celery website (#1638)
The old domain has been compromised. See https://github.com/celery/celeryproject/issues/52 for more information.
2022-04-02 08:06:42 +07:00
Mateusz Soszyński f23c134bfd
Docs: don't break links at the header (#1636) 2022-04-02 08:06:29 +07:00
Michael Hill f4602d30d5
Cross platform simple worker (#1629)
* Added CrossPlatformDeathPenalty that doesn't rely on signals

* Updated `SimpleWorker`'s `death_penalty_class` to utilize `CrossPlatformDeathPenalty` to allow use on Windows machines

* Changed `CrossPlatformDeathPenalty` to `TimerDeathPenalty`

* Removed overridden `death_penalty_class` in `SimpleWorker` until feature matures

* Added section in testing.md explaining how to utilize `SimpleWorker` on Windows OS

* Replaced usage of chatting with .format for python 3.5 compatibility

* Add tests for new timeout feature

* Explicitly set defaults.CALLBACK_TIMEOUT

* Implemented cross-thread method of raising errors by using ctypes

* Finished writing tests for new TimerDeathPenalty
2022-03-10 08:04:24 +07:00
Selwin Ong 609c068ef8
Add codecov.yml to ignore tests directory 2022-03-02 08:25:46 +07:00
Neptalí Piña 34e2427f67
job decorator allow on_failure and on_success parameters (#1626) (#1628)
Co-authored-by: neptali <neptali@plerk.io>
2022-03-02 08:20:30 +07:00
Xavier Fernandez cd17d17d71
rq.worker: remove useless set_state call in horse (#1618)
* rq.worker: remove useless set_state call in horse

The state should already have been set properly by the worker in
`execute_job`

`prepare_job_execution` is only called by `perform_job` which should only be
called by `main_work_horse`/`fork_work_horse` (themselves only called by `execute_job`).
Let `execute_job` do the bookkeeping.

* worker: update SimpleWorker's state in execute_job
2022-02-13 16:15:07 +07:00
Oscar LAURENT 947f8eed33
Remove root logger usage (#1617)
The logging root logger was used in the utils which can cause noise when
inspecting logs. Properly defining a logger and using it as is done
everywhere increase consistency to the overall codebase.

Co-authored-by: olaure <o.s.c.l.a.u.r.e.nt@gmail.com>
2022-02-07 20:00:11 +07:00
th3hamm0r 7be119068f
Fixed job not getting enqueued due to parallel modification (#1615)
The handling of WatchErrors in setup_dependencies() did not reset
the local status of the job, so if, due to parallel processing, all
dependencies get finished while enqueuing the job (causing
WatchError to be raised), the job returned to enqueue_call()
remained in DEFERRED state, which resulted in no execution at all.
2022-01-28 11:08:45 +07:00
th3hamm0r c5a1ef1734
Fixed wrong keys used to WATCH dependencies (#1605)
This bug has opened a lot of possible race-conditions, since the
watch-logic from redis did not fail anymore, if dependencies have been
changed in parallel.
2022-01-03 10:44:42 +07:00
Selwin Ong db445f96b2
Update changelog to mention changes in sync job executions 2021-12-11 18:36:16 +07:00
Kirill Arkhipenko 3f5e94aa8c
fix job.delete with remove_from_queue=False (#1601) 2021-12-11 18:14:02 +07:00
Selwin Ong 97caa841ff Bump version to 1.10.1 2021-12-07 19:45:48 +07:00
Selwin Ong f14dd9e2d7
Replace highlight tag in docs (#1600) 2021-12-07 19:35:56 +07:00
Eric Feldman 93f34c796f
call callbacks and prepare job when running sync (#1599)
* call signals

* fix lines

* add tests and fix faliure status bug

* bump version
2021-12-07 17:20:36 +07:00
Selwin Ong 0147b30f2b
Fixes a bug that causes leftover job keys when result_ttl=0 (#1591)
* Fixes a bug that causes leftover job keys when result_ttl=0

* Fixed a buggy worker.maintain_heartbeats() behavior

* Fixed a bug in worker.maintain_heartbeats().
2021-12-02 07:47:43 +07:00
mgcdanny 76ba690aaf
add REDIS_SSL_CERT_REQS cli parameter (#1495)
* add REDIS_SSL_CERT_REQS cli parameter

* update docs

Co-authored-by: dan <dan@betterfin.com>
2021-10-27 18:52:17 +07:00
rpkak d813ea5e18
put versions in quotes (#1572) 2021-10-11 07:49:18 +07:00
rpkak 6692587f74
Python 3.10 compatibility (#1563)
* use shutil.get_terminal_size instead of click.get_terminal_size()

resolves warning:

rq/cli/helpers.py:107: DeprecationWarning: 'click.get_terminal_size()' is deprecated and will be removed in Click 8.1. Use 'shutil.get_terminal_size()' instead.
  termwidth, _ = click.get_terminal_size()

* remove StrictVersion from rq

* asyncio.get_event_loop -> asyncio.new_event_loop()

resolves warning:

tests/test_job.py::TestJob::test_create_job_with_async
  rq/rq/job.py:839: DeprecationWarning: There is no current event loop
    loop = asyncio.get_event_loop()

* Add python 3.10 to matrix

Co-authored-by: rpkak <rpkak@users.noreply.github.com>
2021-10-07 15:55:25 +07:00
Josh Cohen e71fcb952e
Fix `job.cancel` to remove job from registries if not in queue (#1564)
* Fix `job.cancel` to remove job from registiries if not in queue

* Remove old queue remove call

* Block the ability to cancel job that are already canceled

* Fix py35 compat

* Rename helper method
2021-09-29 07:18:10 +07:00
mike w 47110806d1
bugfix: worker: Launch pubsub thread in `daemon` mode. (#1559)
In #1496, we observed a situation where the `work()` method crashes after
`.subscribe()`, but prior to the `try/except` block which normally cleans up
after `.subscribe()`.

Specifically, `.subscribe()` launches a thread in non-daemon mode. Because of
that setting, Python will keep the calling worker process active, even if the
main thread has crashed. This resulted in a syndrome where a worker process was
running, but doing no work.

The change launches this thread in daemon mode, i.e. prevents a "zombie" pubsub
thread from keeping the process up.

(An additional change we could make, discussed in #1496 but deferred, would be
to improve the error handling/trapping scope in `.work()` such that all
failures trigger resource cleanup.)
2021-09-16 18:20:14 +07:00
Josh Cohen 0d69d08126
RPass serializer to queue at cli (#1556) 2021-09-13 18:50:35 +07:00
Josh Cohen a3fba1ca1f
Add missing functionality for CanceledJobRegistry (#1560) 2021-09-13 18:48:57 +07:00