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
This commit is contained in:
Ethan Wolinsky 2023-07-18 23:46:48 -04:00 committed by GitHub
parent 9933128dd2
commit 89fa8ae0b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View File

@ -818,6 +818,7 @@ class Queue:
"retry": job_data.retry,
"on_success": job_data.on_success,
"on_failure": job_data.on_failure,
"on_stopped": job_data.on_stopped,
}
# Enqueue jobs without dependencies

View File

@ -104,6 +104,18 @@ class QueueCallbackTestCase(RQTestCase):
job = Job.fetch(id=job.id, connection=self.testconn)
self.assertEqual(job.stopped_callback, print)
def test_enqueue_many_callback(self):
queue = Queue('example', connection=self.testconn)
job_data = Queue.prepare_data(
func=say_hello, on_success=print, on_failure=save_exception, on_stopped=save_result_if_not_stopped
)
jobs = queue.enqueue_many([job_data])
assert jobs[0].success_callback == job_data.on_success
assert jobs[0].failure_callback == job_data.on_failure
assert jobs[0].stopped_callback == job_data.on_stopped
class SyncJobCallback(RQTestCase):
def test_success_callback(self):