Skip to content

Commit

Permalink
perf(agent): Poll jobs from servers without recent failures
Browse files Browse the repository at this point in the history
  • Loading branch information
adityahase committed Jan 16, 2025
1 parent 0fca778 commit 3acaf03
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion press/press/doctype/agent_job/agent_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,17 @@ def filter_active_servers(servers):
return active_servers


def filter_request_failures(servers):
request_failures = set(frappe.get_all("Agent Request Failure", pluck="server"))

alive_servers = []
for server in servers:
if server.server not in request_failures:
alive_servers.append(server)

return alive_servers


def poll_pending_jobs():
servers = frappe.get_all(
"Agent Job",
Expand All @@ -595,7 +606,9 @@ def poll_pending_jobs():
)

active_servers = filter_active_servers(servers)
for server in active_servers:
alive_servers = filter_request_failures(active_servers)

for server in alive_servers:
frappe.enqueue(
"press.press.doctype.agent_job.agent_job.poll_pending_jobs_server",
queue="short",
Expand Down

0 comments on commit 3acaf03

Please sign in to comment.