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: use name for RQ worker instead of PID #25175

Merged
merged 1 commit into from Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions frappe/core/doctype/rq_worker/rq_worker.json
Expand Up @@ -114,7 +114,7 @@
"in_create": 1,
"is_virtual": 1,
"links": [],
"modified": "2024-01-13 10:36:13.034784",
"modified": "2024-02-29 19:31:08.502527",
"modified_by": "Administrator",
"module": "Core",
"name": "RQ Worker",
Expand All @@ -141,5 +141,6 @@
"color": "Yellow",
"title": "busy"
}
]
],
"title_field": "pid"
}
4 changes: 2 additions & 2 deletions frappe/core/doctype/rq_worker/rq_worker.py
Expand Up @@ -38,7 +38,7 @@ class RQWorker(Document):

def load_from_db(self):
all_workers = get_workers()
workers = [w for w in all_workers if w.pid == cint(self.name)]
workers = [w for w in all_workers if w.name == self.name]
if not workers:
raise frappe.DoesNotExistError
d = serialize_worker(workers[0])
Expand Down Expand Up @@ -85,7 +85,7 @@ def serialize_worker(worker: Worker) -> frappe._dict:
current_job = None

return frappe._dict(
name=worker.pid,
name=worker.name,
queue=queue,
queue_type=queue_types,
worker_name=worker.name,
Expand Down
2 changes: 1 addition & 1 deletion frappe/core/doctype/rq_worker/test_rq_worker.py
Expand Up @@ -14,4 +14,4 @@ def test_get_worker_list(self):

def test_worker_serialization(self):
workers = RQWorker.get_list({})
frappe.get_doc("RQ Worker", workers[0].pid)
frappe.get_doc("RQ Worker", workers[0].name)
3 changes: 1 addition & 2 deletions frappe/utils/background_jobs.py
Expand Up @@ -291,7 +291,6 @@ def start_worker(
if queue:
queue = [q.strip() for q in queue.split(",")]
queues = get_queue_list(queue, build_queue_name=True)
queue_name = queue and generate_qname(queue)

if os.environ.get("CI"):
setup_loghandlers("ERROR")
Expand All @@ -302,7 +301,7 @@ def start_worker(
if quiet:
logging_level = "WARNING"

worker = Worker(queues, name=get_worker_name(queue_name), connection=redis_connection)
worker = Worker(queues, connection=redis_connection)
worker.work(
logging_level=logging_level,
burst=burst,
Expand Down