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

Fixing Worker Pool race condition for assignments #875

Merged
merged 3 commits into from
Aug 1, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion mephisto/operations/worker_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ async def _assign_unit_to_agent(
else:
# See if the concurrent unit is ready to launch
assignment = await loop.run_in_executor(None, unit.get_assignment)
logger.debug(f"Attempting to launch {assignment}.")
agents = await loop.run_in_executor(None, assignment.get_agents)
if None in agents:
agent.update_status(AgentState.STATUS_WAITING)
Expand All @@ -275,10 +276,15 @@ async def _assign_unit_to_agent(
non_null_agents = [a for a in agents if a is not None]
# Launch the backend for this assignment
registered_agents = [
self.agents[a.get_agent_id()]
self.agents.get(a.get_agent_id())
for a in non_null_agents
if a is not None
]
if None in registered_agents:
# an Agent has been matched to the Assignment, but isn't yet watched
# by the pool. Wait for that thread to catch up
logger.debug(f"Delaying launch of {assignment}, should retry.")
return

live_run.task_runner.execute_assignment(assignment, registered_agents)

Expand Down