Commit Graph

1839 Commits

Author SHA1 Message Date
Stanislav Khlud e21ce4e255
Extend ssl config options (#2066) 2024-04-13 06:43:55 +07:00
Ethan Wolinsky 2fc5484852
Execute custom handlers when abandoned job is found (#2057)
* Execute custom handlers when abandoned job is found

* Make exception_handlers optional

* Run exception handlers before checking retry

* Test abandoned job handler is called

* Improve test coverage

* Fix handler order
2024-03-23 16:46:07 +07:00
Selwin Ong bab0061da1
Removed utils.utcnow() (#2056)
* Bump version to 1.16.1

* Partially replaced utcnow() with now()

* Removed utils.utcnow

* Fix lint
2024-03-11 19:44:12 +07:00
Ethan Wolinsky 3a3787dcc3
Group jobs into batches and retrieve by batch name (#1945)
* Batch.py initial commit

* Add method to refresh batch status

* Clean up Redis key properties

* Remove persist_job method

* Execute refresh method when fetching batch

* Add batch_id to job

* Add option to batch jobs with enqueue_many

* Add set_batch_id method

* Handle batch_ttl when job is started

* Renew ttl on all jobs in batch when a job finishes

* Use fetch_jobs method in refresh()

* Remove batch TTL

During worker maintenance task, worker will loop through batches and
delete expired jobs.
When all jobs are expired, the batch is deleted.

* Fix buggy connection

* Raise batch error in fetch method

* Fix fetch connection arg

* Add testing for batch

* Remove unused import

* Update batch documentation

* Add batch ID to job persistence test

* Test that empty batch is removed from batch list

* Make default batch ID full uuid4 to match Job

* Add method to return batch key

* Add all method to return iterable of batches

* Revert changes to queue.py

* Separate batch creating from job enqueueing.

Batches can be created by passing an array of jobs.

* Fix bug with stopped callback in enqueue_many

* Rename delete_expired_jobs batch method

* Use exists to identify expired jobs

* Remove jobs attribute from batch

Jobs have to be explicitly fetched using the get_jobs method

* Don't add batch_id to job in _add_jobs method

This should be done when the job is created before it is saved to redis.

* Use cleanup method to determine if batch should be deleted

* Add get_jobs method

This method will return an array of jobs belonging to the batch.

* Update create method to not allow jobs arg

Jobs should be added to batches in the Queue.enqueue_many
function

* Add batch_id to job create method

* Delete set_batch_id method

The batch ID should be set atomically when the job is created

* Add batch argument to queue.enqueue_many

This will be how jobs can be batched. The batch ID is added to each job
created by enqueue_many, and then those jobs are all added to the batch
in Redis using the batch's _add_jobs method

* Update batch tests to use new enqueue_many arg

* Fix batch_id for non_batched jobs

* Use different pipeline name

* Don't use fetch method when enqueuing jobs

If the batch is empty, fetch will delete it from Redis

* Test enqueuing batched jobs with string ID

* Update batch documentation

* Remove unused variables

* Fix expired job tracking bug

* Add delete_job method

* Use delete_job method on batch

* Pass multiple jobs into srem command

* Add multiple keys to exists call

* Pipeline _add_jobs call

* Fix missing job_id arg

* Move clean_batch_registry to Batch class

* Remove unused variables

* Fix missing dependency deletion

I accidentally deleted this earlier

* Move batch enqueueing to batch class

* Update batch docs

* Add test for batched jobs with str queue arg

* Don't delete batch in cleanup

* Change Batch to Group

* Import EnqueueData for type hint

* Sort imports

* Remove local config file

* Rename clean_group_registries method

* Update feature version

* Fix group constant names

* Only allow Queue in enqueue many

* Move cleanup logic to classmethod

* Remove str group test

* Remove unused import

* Make pipeline mandatory in _add_jobs method

* Rename expired job ids array

* Add slow decorator

* Assert job 1 data in group

* Rename id arg to name

* Only run cleanup when jobs are retrieved

* Remove job_ids variable

* Fix group name arg

* Fix group name arg

* Clean groups before fetching

* Use uuid4().hex for shorter id

* Move cleanup logic to instance method

* Use all method when cleaning group registry

* Check if group exists instead of catching error

* Cleanup expired jobs

* Apply black formatting

* Fix black formatting

* Pipeline group cleanup

* Fix pipeline call to exists

* Add pyenv version file

* Remove group cleanup after job completes

* Use existing pipeline

* Remove unneeded pipeline check

* Fix empty call

* Test group __repr__ method

* Remove unnecessary pipeline assignment

* Remove unused delete method

* Fix pipeline name

* Remove unnecessary conditional block
2024-03-11 15:08:53 +07:00
dewalujjwal cdf5cfcd3d
Replace deprecated utcnow() with timezone aware now() (#2055)
* changed the utcnow() to now()

* changed the utcnow() to now()

* changed the utcnow() to now()

* changed the utcnow() to now()

* changed the utcnow() to now()

* changed the utcnow() to now()

* changed the utcnow() to now()

* changed the utcnow() to now()
2024-03-11 08:00:46 +07:00
Selwin Ong e2a1011074
Added worker_pool.get_worker_process() (#2052) 2024-03-09 09:28:23 +07:00
Selwin Ong 3ad86083c3 Merge tag 'v1.16' 2024-02-25 08:10:01 +07:00
Selwin Ong 34f83d637f Remove Python 3.6 from test matrix 2024-02-24 11:50:40 +07:00
Selwin Ong e98509434e Workflow syntax 2 2024-02-24 10:31:33 +07:00
Selwin Ong b8d2750c17 Workflow syntax 2024-02-24 10:30:42 +07:00
Selwin Ong 6ca0a299c8 Run on push to all branches 2024-02-24 10:29:23 +07:00
Selwin Ong e50b8f323d Always run github actions on push 2024-02-24 10:24:33 +07:00
Selwin Ong 97b2d83164 Minor test case change to trigger Github Actions 2024-02-24 10:19:23 +07:00
Selwin Ong 6ce1cc63b9 Bump version to 1.16.0 2024-02-24 10:10:21 +07:00
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
Ethan Wolinsky 690a6451db
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:44:44 +07:00
Selwin Ong 67624eba0b
Deprecate current connection (#2043)
* Removed pop_connection from Worker.find_by_key()

* Removed push_connection from worker.work()

* Remove push_connection from workers.py and cli

* Remove get_current_connection() from worker._set_connection()

* Fix failing tests

* Removed the use of get_current_connection()

* WIP removing get_connection()

* Fixed tests in test_dependencies.py

* Fixed a few test files

* test_worker.py now passes

* Fix HerokuWorker

* Fix schedule_access_self test

* Fix ruff errors
2024-02-21 07:37:15 +07:00
Selwin Ong 16fa7e837a
Added polarsource to FUNDING.yml 2024-02-19 08:48:15 +07:00
dependabot[bot] 133d18dfb2
Bump codecov/codecov-action from 3 to 4 (#2032)
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 3 to 4.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/codecov/codecov-action/compare/v3...v4)

---
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>
2024-02-14 19:22:56 +07:00
Christofer Saputra dcf644596d
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-13 09:33:06 +07:00
Arne Strickmann cfc1af992c
Update README.md (#2036)
Our first open source project: 

RQ Dashboard based on FastAPI 

The Goal is to make the integration of an RQ Dashboard into FastAPI applications easier.
2024-02-13 09:32:27 +07:00
Péter Gyarmati 2f5fecc1ba
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-01-19 07:21:26 +07:00
Péter Gyarmati e2b600d9df
docs: fix typo in `workers.md` (#2023)
"shuttind" -> "shutting"
2024-01-13 09:02:00 +07:00
Mindiell a8209391ff
Fix 'quiet' option for 'worker_pool' comand (#2010)
* Fix 'quiet' option for 'worker_pool' comand

* Added test for 'quiet' option

---------

Co-authored-by: Mindiell <mindiell@mindiell.net>
2023-12-24 10:16:18 +07:00
Mathieu Défosse 960d9e5123
chore(logging): add logging for job retries (#2012) 2023-12-24 09:54:25 +07:00
dependabot[bot] 3b18d75f36
Bump actions/setup-python from 4.7.1 to 5.0.0 (#2013)
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4.7.1 to 5.0.0.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/v4.7.1...v5.0.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>
2023-12-19 18:32:35 +08:00
dependabot[bot] ed4abd4448
Bump actions/download-artifact from 3 to 4 (#2018)
Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 3 to 4.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](https://github.com/actions/download-artifact/compare/v3...v4)

---
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>
2023-12-19 18:32:08 +08:00
dependabot[bot] 6bd43325eb
Bump actions/upload-artifact from 3 to 4 (#2019)
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 3 to 4.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v3...v4)

---
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>
2023-12-19 18:31:52 +08:00
dependabot[bot] 02d712d995
Bump github/codeql-action from 2 to 3 (#2017)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2 to 3.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/v2...v3)

---
updated-dependencies:
- dependency-name: github/codeql-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-12-18 21:02:33 +08:00
dependabot[bot] 59e92666c7
Bump supercharge/redis-github-action from 1.7.0 to 1.8.0 (#2016)
Bumps [supercharge/redis-github-action](https://github.com/supercharge/redis-github-action) from 1.7.0 to 1.8.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.7.0...1.8.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>
2023-12-18 21:02:18 +08:00
Conor d11094af95
Typo: serialzers in workers.md (#2000) 2023-11-24 19:33:02 +07:00
Yamil Asusta 8965b4ca3b
Allow CA be passed as a variable (#1969)
* Allow CA be passed as a variable

* Add docs for SSL_CA_DATA
2023-11-11 08:01:15 +07:00
Selwin Ong 3c89f9dada
Job with multiple executions (#1964)
* Initial work on Execution class

* Executions are now created and deleted when jobs are performed

* Added execution.heartbeat()

* Added a way to get execution IDs from execution registry

* Job.fetch should also support execution composite key

* Added ExecutionRegistry.get_executions()

* execution.heartbeat() now also updates StartedJobRegistry

* Added job.get_executions()

* Added worker.prepare_execution()

* Simplified start_worker function in fixtures.py

* Minor test fixes

* Black

* Fixed a failing shutdown test

* Removed Execution.create from worker.prepare_job_execution

* Fix Sentry test

* Minor fixes

* Better test coverage

* Readded back worker.set_current_job_working_time()

* Reverse the order of handle_exception and handle_job_failure

* Fix SSL test

* job.delete() also deletes executions.

* Set job._status to FAILED as soon as job raises an exception

* Exclusively use execution.composite_key in StartedJobRegistry

* Use codecov v3

* Format with black

* Remove print statement

* Remove Redis server 3 from tests

* Remove support for Redis server < 4

* Fixed ruff warnings

* Added tests and remove unused code

* Linting fixes
2023-11-03 17:05:59 +07:00
dependabot[bot] 4973e01a7e
Bump supercharge/redis-github-action from 1.6.0 to 1.7.0 (#1972)
Bumps [supercharge/redis-github-action](https://github.com/supercharge/redis-github-action) from 1.6.0 to 1.7.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.6.0...1.7.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>
2023-10-18 22:56:26 +07:00
Simó Albert i Beltran 235a87d01e
fix_cleanup_ghosts_by_using_configured_worker_class (#1988)
Signed-off-by: Simó Albert i Beltran <sim6@bona.gent>
2023-10-07 07:09:32 +07:00
dependabot[bot] 626378cb32
Bump actions/setup-python from 4.7.0 to 4.7.1 (#1987)
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4.7.0 to 4.7.1.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/v4.7.0...v4.7.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-10-07 07:08:30 +07:00
dependabot[bot] 24d38c8927
Bump codecov/codecov-action from 3 to 4 (#1981)
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 3 to 4.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/codecov/codecov-action/compare/v3...v4)

---
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>
2023-10-07 07:07:11 +07:00
Craig de Stigter a044248430
Don't use `os.setsid()` after forking workhorse (#1970)
In 9adcd7e50c a change was made to make
the workhorse process into a session leader. This appears to have been
done in order to set the process group ID of the workhorse so that it
can be killed easily along with its descendants when
`Worker.kill_horse()` is called.

However, `setsid` is overkill for this purpose; it sets not only the
process group ID but also the session ID. This can cause issues for user
jobs which may rely on session IDs being less-than-unique for arbitrary
reasons.

This change switches to `setpgrp`; this sets the process group ID so
that the workhorse and its descendants can be killed *without* changing
the session ID.
2023-09-23 17:35:29 +07:00
Selwin Ong 0f4d041578
Worker methods cleanup (#1967)
* Moved some common methods to BaseWorker

* Cleaned up more worker methods

* Warning cleanups

* Fix tests
2023-08-17 08:44:46 +07:00
Selwin Ong 6b11c3ee2a
Moved some common methods to BaseWorker (#1965)
* Moved some common methods to BaseWorker

* Cleaned up more worker methods
2023-08-13 07:56:20 +07:00
dependabot[bot] baccb6c04d
Bump supercharge/redis-github-action from 1.5.0 to 1.6.0 (#1959)
Bumps [supercharge/redis-github-action](https://github.com/supercharge/redis-github-action) from 1.5.0 to 1.6.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.5.0...1.6.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>
2023-08-05 09:53:35 +07:00
dependabot[bot] 953b85eefb
Bump actions/setup-python from 4.6.1 to 4.7.0 (#1957)
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4.6.1 to 4.7.0.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/v4.6.1...v4.7.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-07-21 15:54:39 +07:00
Ethan Wolinsky 89fa8ae0b5
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
2023-07-19 10:46:48 +07:00
Rob Hudson 9933128dd2
Store project metadata in pyproject.toml (PEP 621) (#1952) 2023-07-09 17:34:25 +07:00