Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Add missing connection parameter for jobs with dependencies #500

Merged
merged 1 commit into from
Dec 10, 2024

Conversation

prepin
Copy link
Contributor

@prepin prepin commented Dec 9, 2024

Description

Fixes display of RQ tasks that have other task they depend on. Connection parameter was missing in code that fetches dependencies. It is required as of RQ 2.0 (see #495).

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • [ x] I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have run tests (pytest) that prove my fix is effective or that my feature works
  • I have updated the CHANGELOG.md file accordingly
  • I have added tests that prove my fix is effective or that my feature works

Testing

hello.py

from redis import Redis
from rq.queue import Queue

from tasks import download, review

redis_conn = Redis()
q = Queue("default", connection=redis_conn)


def main():
    download_job = q.enqueue(download, "Filename.txt")
    review_job = q.enqueue(review, args=[download_job.id], depends_on=download_job)


if __name__ == "__main__":
    main()

tasks.py

from redis import Redis
from rq.job import Job


def download(name):
    return f"{name} Downloaded "


def review(job_id):
    download_job = Job.fetch(job_id, connection=Redis())
    result = download_job.return_value()
    if result:
        download_result = result + "and Reviewed"
        return download_result
    return "no result"

Run hello.py and open review job in RQ-Dashboard.

@cjlapao cjlapao merged commit 0a84a8c into Parallels:master Dec 10, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants