summaryrefslogtreecommitdiff
path: root/tests/test_queue.py
Commit message (Collapse)AuthorAgeFilesLines
* Update linting configuration (#1915)Rob Hudson2023-05-171-4/+3
| | | | | | | | | * 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
* Worker pool (#1874)Selwin Ong2023-05-011-97/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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 a1306f89ad0d8686c6bde447bff75e2f71f0733b. * 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
* Improve the lint situation (#1688)Yang Yang2022-08-071-1/+1
| | | | | | | | | | * Move common flake8 options into config file Currently --max-line-length being specified in two places. Just use the existing value in the config file as the source of truth. Move --count and --statistics to config file as well. * Fix some lints
* Drop python2-specific syntax (#1674)Hugo2022-07-241-4/+0
| | | | | | | * Drop syntax required only for Python 2 * Drop python2-style super() calls Co-authored-by: Selwin Ong <selwin.ong@gmail.com>
* Use unittest.mock instead of mock (#1673)Hugo2022-07-241-1/+1
| | | | | This module has been included in Python itself since 3.3. Fixes: https://github.com/rq/rq/issues/1646
* Add missing functionality for CanceledJobRegistry (#1560)Josh Cohen2021-09-131-1/+4
|
* Respect serializer (#1538)Josh Cohen2021-08-241-1/+18
| | | | | | | | | | | | | | * Add serializer where missing in code * Fix cli * Pass option to command * Add tests for serializer option * Merge branch 'master' into respect-serializer - Update enqueue cli to resp. serializer * Address @selwin's review
* Use result_ttl for synchronous queues (#1510)Bo Bayles2021-07-191-0/+12
|
* Ensure pipeline in multi mode after dep setup (#1498)Josh Cohen2021-06-221-0/+16
|
* Make `Queue.enqueue`, `Queue.enqueue_call`, ↵Josh Cohen2021-06-201-1/+95
| | | | | | | | | | | | | | | | | | | | | | | | | `Queue.enqueue_at``Queue.parse_args` accept `pipeline` arg, add `Queue.enqueue_many` method (#1485) * Make `enqueue_*` and `Queue.parse_args` accept `pipeline` arg * undo bad docs * Fix lints in new code * Implement enqueue_many, refactor dependency setup out to method * Make name consistant * Refactor enqueue_many, update tests, add docs * Refactor out enqueueing from dependency setup * Move new docs to queue page * Fix section header * Fix section header again * Update rq version to 1.9.0
* Added job.worker_name (#1375)Selwin Ong2020-11-081-6/+3
| | | | | | | | | | | * Added job.worker_name * Fix compatibility with Redis server 3.x * Document job.worker_name * Removed some Python 2 compatibility stuff. * Remove unused codes
* get_redis_server_version() should handle 4 digit version numbers (#1322)Selwin Ong2020-08-161-1/+1
|
* Job retry feature. Docs WIP (#1299)Selwin Ong2020-07-231-1/+10
| | | | | | | | | | | | | | | * Initial implementation of Retry class * Fixes job.refresh() under Python 3.5 * Remove the use of text_type in job.py * Retry can be scheduled * monitor_work_horse() should call handle_job_failure() with queue argument. * Flake8 fixes * Added docs for job retries
* Add get_job_position and get_position feature (#1271)Paul Spooren2020-06-281-0/+12
| | | | | Fix #1197 Signed-off-by: Paul Spooren <mail@aparcar.org>
* Address Deleted Dependenciesthomas2020-04-161-14/+0
| | | | | | | | | | 1) Check if `created_at` when checking if dependencies are met. If `created_at` is `None` then the job has been deleted. This is sort of hack - we just need one of the fields on the job's hash that is ALWAYS populated. You can persist a job to redis without setting status... 2) Job#fetch_dependencies no longer raises NoSuchJob. If one of a job's dependencies has been deleted from Redis, it is not returned from `fetch_dependencies` and no exception is raised.
* Fix patches for python2thomas2020-04-161-40/+30
|
* Alway set status 'FINISHED' when job is Successfulthomas2020-04-161-7/+20
| | | | | | | | Method Queue#enqueue_dependents checks the status of all dependencies of all dependents, and enqueues those dependents for which all dependencies are FINISHED. The enqueue_dependents method WAS called from Worker#handle_job_success called BEFORE the status of the successful job was set in Redis, so enqueue_dependents explicitly excluded the _successful_ job from interrogation of dependency statuses as the it would never be true in the existing code path, but it was assumed that this would be final status after the current pipeline was executed. This commit changes Worker#handle_job_success so that it persists the status of the successful job to Redis, everytime a job completes(not only if it has a ttl) and does so before enqueue_dependents is called. This allows for enqueue_dependents to be less reliant on the out of band state of the current _successful job being handled_.
* Only enqueue dependents for all dependencies are FINISHEDthomas2020-04-161-0/+97
|
* Implement Customizable Serializer Support (#1219)Babatunde Olusola2020-04-161-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | * Implement Customizable Serializer Support * Refractor serializer instance methods * Update tests with other serializers * Edit function description * Edit function description * Raise appropriate exception * Update tests for better code coverage * Remove un-used imports and un-necessary code * Refractor resolve_serializer * Remove un-necessary alias from imports * Add documentation * Refractor tests, improve documentation
* enqueue_at should support explicit args and kwargs (#1211)Selwin Ong2020-03-081-0/+13
|
* Job scheduling (#1163)Selwin Ong2020-01-041-3/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * First RQScheduler prototype * WIP job scheduling * Fixed Python 2.7 tests * Added ScheduledJobRegistry.get_scheduled_time(job) * WIP on scheduler's threading mechanism * Fixed test errors * Changed scheduler.acquire_locks() to instance method * Added scheduler.prepare_registries() * Somewhat working implementation of RQ scheduler * Only call stop_scheduler if there's a scheduler present * Use OSError rather than ProcessLookupError for PyPy compatibility * Added `auto_start` argument to scheduler.acquire_locks() * Make RQScheduler play better with timezone * Fixed test error * Added --with-scheduler flag to rq worker CLI * Fix tests on Python 2.x * More Python 2 fixes * Only call `scheduler.start` if worker is run in non burst mode * Fixed an issue where running worker with scheduler would fail sometimes * Make `worker.stop_scheduler()` more resilient to errors * worker.dequeue_job_and_maintain_ttl() should also periodically run maintenance tasks * Scheduler can now work with worker in both burst and non burst mode * Fixed scheduler logging message * Always log scheduler errors when running * Improve scheduler error logging message * Removed testing code * Scheduler should periodically try to acquire locks for other queues it doesn't have * Added tests for scheduler.should_reacquire_locks * Added queue.enqueue_in() * Fixes queue.enqueue_in() in Python 2.7 * First stab at documenting job scheduling * Remove unused methods * Remove Python 2.6 logging compatibility code * Remove more unused imports * Added convenience methods to access job registries from queue * Added test for worker.run_maintenance_tasks() * Simplify worker.queue_names() and worker.queue_keys() * Updated changelog to mention RQ's new job scheduling mechanism.
* Multi Dependency Support - Registration & Enqueue Call (#1155)Thomas Matecki2019-11-261-6/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Multi Dependency Support - Registration & Enqueue Call Internal API changes to support multiple dependencies. * Store all of a job's _dependencies_ in a redis set. Delete that set when a job is deleted. * Add Job#fetch_dependencies method - which return all jobs a job is dependent upon and optionally _WATCHES_ all dependency ids. * Use Job#fetch_dependencies in Queue#call_enqueue. `fetch_dependencies` now sets WATCH and raises InvalidJobDependency, rather than call_enqueue. `Queue` and `Job` public APIs still expect single ids of jobs for `depends_on` but internally register them in a way that could support multiple jobs being passed as dependencies. Next up: need to update Queue#enqueue_dependents * Use existing fetch_many method to get dependencies. Modify fetch_dependencies to use fetch_many. * Remove default value for fetch_many's connection parameter * PR review housekeeping * Remove a duplicate test * Oneline something * Fix missing colon in dependencies key * Delete job key, dependents and dependencies at once * More Fixes From Code Review Updates to Job, Queue and associated tests. * When Checking dependencies Avoid, trip to Redis * When checking the status of a job, we have a 'clean' status of all dependencies(returned from Job#fetch_dependencies) and the job keys are WATCHed, so there's no reason to go back to Redis to get the status _again_. * Looks as though, the `_status` set in `Job#restore` was bytes while it was converted to text(`as_text`) in `Job#get_status` - for consistency(and tests) converting to text in `restore` as well. * In `Queue#enqueue_call`, moved WATCH of dependencies_key to before fetching dependencies. This doesn't really matter but seems more _correct_ - one can imagine some rogue API adding a dependency after they've been fetched but before they've been WATCHEed. * Update Job#get_status to get _local_ status * If refresh=False is passed, don't get status from Redis; return the value of _status. This is to avoid a trip to Redis if the caller can guarantee that the value of `_status` is _clean_. * More Fixups * Expire dependency keys in Job#cleanup * Consistency in Job#fetch_dependencies
* Added logging statements to handle_job_success and handle_job_failure (#1112)Selwin Ong2019-06-221-1/+1
|
* Added checks for 0 ttl (#1110)Selwin Ong2019-06-161-0/+13
|
* RQ v1.0! (#1059)Selwin Ong2019-03-301-235/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Added FailedJobRegistry. * Added job.failure_ttl. * queue.enqueue() now supports failure_ttl * Added registry.get_queue(). * FailedJobRegistry.add() now assigns DEFAULT_FAILURE_TTL. * StartedJobRegistry.cleanup() now moves expired jobs to FailedJobRegistry. * Failed jobs are now added to FailedJobRegistry. * Added FailedJobRegistry.requeue() * Document the new `FailedJobRegistry` and changes in custom exception handler behavior. * Added worker.disable_default_exception_handler. * Document --disable-default-exception-handler option. * Deleted worker.failed_queue. * Deleted "move_to_failed_queue" exception handler. * StartedJobRegistry should no longer move jobs to FailedQueue. * Deleted requeue_job * Fixed test error. * Make requeue cli command work with FailedJobRegistry * Added .pytest_cache to gitignore. * Custom exception handlers are no longer run in reverse * Restored requeue_job function * Removed get_failed_queue * Deleted FailedQueue * Updated changelog. * Document `failure_ttl` * Updated docs. * Remove job.status * Fixed typo in test_registry.py * Replaced _pipeline() with pipeline() * FailedJobRegistry no longer fails on redis-py>=3 * Fixes test_clean_registries * Worker names are now randomized * Added a note about random worker names in CHANGES.md * Worker will now stop working when encountering an unhandled exception. * Worker should reraise SystemExit on cold shutdowns * Added anchor.js to docs * Support for Sentry-SDK (#1045) * Updated RQ to support sentry-sdk * Document Sentry integration * Install sentry-sdk before running tests * Improved rq info CLI command to be more efficient when displaying lar… (#1046) * Improved rq info CLI command to be more efficient when displaying large number of workers * Fixed an rq info --by-queue bug * Fixed worker.total_working_time bug (#1047) * queue.enqueue() no longer accepts `timeout` argument (#1055) * Clean worker registry (#1056) * queue.enqueue() no longer accepts `timeout` argument * Added clean_worker_registry() * Show worker hostname and PID on cli (#1058) * Show worker hostname and PID on cli * Improve test coverage * Remove Redis version check when SSL is used * Bump version to 1.0 * Removed pytest_cache/README.md * Changed worker logging to use exc_info=True * Removed unused queue.dequeue() * Fixed typo in CHANGES.md * setup_loghandlers() should always call logger.setLevel() if specified
* Fix #1040 queue default timeout bug. (#1042)Wolfgang Langner2019-02-231-0/+18
| | | Add test for queue default_timeout.
* Replace "timeout" argument in queue.enqueue() with "job_timeout" (#1010)Selwin Ong2018-11-221-2/+11
|
* add is_async property to queue (#982)Paul Robertson2018-08-081-0/+7
|
* Replace 'async' keyword with 'is_async' for Queue objects (#977)chevell2018-07-071-2/+2
| | | | | | | | | | * Replaced async keyword with is_async in the Queue class to fix reserved keyword syntax errors in Python 3.7 * Updated tests to use is_async keyword when instantiating Queue objects * Updated docs to reference is_async keyword for Queue objects * Updated tox.ini, setup.py and .travis.yml with references to Python 3.7
* Merge pull request #878 from theodesp/Issue-731Selwin Ong2017-10-241-0/+32
|\ | | | | Fixed #731 - Support for deleting Queues
| * Fixed #731 - Code review issues. Added delete_jobs parameter and pipelining.Theo2017-10-041-2/+20
| |
| * Fixed #731 - Support for deleting QueuesTheo2017-09-081-0/+14
| |
* | Fixed #866 - Flak8 errorsTheo2017-09-081-3/+3
|/
* revert back job.cleanup changesAlexey Katichev2017-05-221-2/+3
|
* remove implicit cleanup call from job.saveAlexey Katichev2017-05-071-0/+12
|
* job.delete() should cleans itself from FailedQueue and various registries.Selwin Ong2017-04-011-0/+17
|
* Allow passing backend classes (job, queue, worker, connection) from CLI and ↵Jannis Leidel2017-01-251-1/+38
| | | | | | | | | | | other APIs This includes: - a partial refactor of the CLI to organize the shared options - extends the tests in areas where passing custom backend classes makes sense - allow setting the core CLI options as env vars - minor cosmetic changes here and there
* Another check on failed status and testJulien Surloppe2016-12-031-0/+21
|
* fetch_job - check correct queue, fix #728Samuel Colvin2016-09-201-0/+26
|
* Raise an exception if a given dependency does not existStefan Hammer2016-08-251-1/+18
| | | | Adapted some tests to the change: the dependency has to be saved first.
* Test the worker in its own subprocessArnold Krille2016-06-151-6/+12
| | | | | | | | | | | | | - run with an empty queue - schedule one job (which uses get_current_connection and get_current_job) and run `rqworker` - schedule a job that itself schedules `access_self` and run `rqworker` - Make sure the job didn't fail by assuring the failed queue is still empty afterwards. - Install this package locally when running in travis. This actually unifies the behaviour of tox and travis as tox also builds the package and then installs it into each test environment. - fix flake8 (as run by tox)
* Fix indentation and newlines according to flake8Arnold Krille2016-03-131-5/+2
|
* Typo in test docstringAntoine Leclair2016-02-151-1/+1
|
* Merge pull request #609 from tornstrom/masterSelwin Ong2015-12-061-0/+7
|\ | | | | Allow meta when enqueing
| * Allow meta when enqueingTornstrom2015-11-301-0/+7
| |
* | Merge pull request #600 from glaslos/cancel_removeSelwin Ong2015-11-231-3/+1
|\ \ | | | | | | Cancel and Delete differences
| * | delete dependents and delete in cleanup. Fixed tests.glaslos2015-11-061-3/+1
| |/
* | fix testsahxxm2015-11-091-55/+55
|/ | | | | syntax: assertEquals -> assertEqual, assertNotEquals -> assertNotEqual usage: status of worker and job now will use get/set method instead of property method
* Clarify test_enqueue_dependents_on_multiple_queuesJavier Lopez2015-08-241-1/+2
|
* Add test_enqueue_dependents_on_mulitple_queues testJavier Lopez2015-08-241-0/+38
|