Skip to content

Commit

Permalink
Fixes test
Browse files Browse the repository at this point in the history
  • Loading branch information
lowellausen-karelics committed Aug 5, 2024
1 parent fd18976 commit 7ce0604
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion task_manager/task_manager/task_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def __init__(
)

self._client = self._service_clients[task_specs.task_name]
self.cancel_task_timeout = 5.0 # Timeout to wait for task to cancel
self.cancel_task_timeout = task_specs.cancel_timeout # Timeout to wait for task to cancel

@property
def task_details(self) -> TaskDetails:
Expand Down
3 changes: 0 additions & 3 deletions task_manager/task_manager/task_registrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ def __init__(
self._action_clients: Dict[str, ActionClient] = {} # [task_name, ActionClient]
self._service_clients: Dict[str, Client] = {} # [task_name, Client]

self.cancel_task_timeout = 5

def start_new_task(self, request: ExecuteTask.Goal, task_specs: TaskSpecs) -> TaskClient:
"""Starts a task and cancels any conflicting tasks.
Expand Down Expand Up @@ -118,7 +116,6 @@ def start_new_task(self, request: ExecuteTask.Goal, task_specs: TaskSpecs) -> Ta
)
msg_interface = task_specs.msg_interface.Request()

task_client.cancel_task_timeout = self.cancel_task_timeout
task_client.register_done_callback(self._task_done_cb)

task_goal_message = populate_msg(task_data=request.task_data, msg_interface=msg_interface)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ def add_task(self, task_specs: TaskSpecs):
Parameter(name=f"{task_specs.task_name}.msg_interface", value=task_specs.msg_interface),
Parameter(name=f"{task_specs.task_name}.blocking", value=task_specs.blocking),
Parameter(name=f"{task_specs.task_name}.cancel_on_stop", value=task_specs.cancel_on_stop),
Parameter(name=f"{task_specs.task_name}.cancel_timeout", value=task_specs.cancel_timeout),
]
)
self._tasks.append(task_specs.task_name)
Expand Down Expand Up @@ -239,6 +240,7 @@ def add_service_task_add_two_ints(self, task_name, blocking=False):
task_server_type=TaskServerType.SERVICE,
blocking=blocking,
cancel_on_stop=False,
cancel_timeout=1.5,
)
)

Expand Down
4 changes: 1 addition & 3 deletions task_manager/test/integration_tests/test_task_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,7 @@ def test_two_non_blocking_tasks(self) -> None:
def test_blocking_task_cancelling_fails(self) -> None:
"""Sometimes blocking task cancelling might fail, for example if we try to cancel a service that executes for
more than the cancel timeout."""
self.task_manager_node.task_registrator.cancel_task_timeout = 0.1

goal_handle_1 = self.start_add_two_ints_service_task(run_time_secs=1)
goal_handle_1 = self.start_add_two_ints_service_task(run_time_secs=2)

# New blocking Service Task should cancel the previous task
goal_handle_2 = self.start_add_two_ints_service_task(run_time_secs=1)
Expand Down

0 comments on commit 7ce0604

Please sign in to comment.