From 304c3cade4409d2dd42c57070b5ac4aa9f620732 Mon Sep 17 00:00:00 2001 From: Richard Liaw Date: Sun, 29 Oct 2017 00:49:29 -0700 Subject: [PATCH] [tune] 10 second timeout for stopping (#1169) * 10 second timeout for stopping * prints for travis * lint * try better returning mechanism * lint --- python/ray/tune/trial.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/python/ray/tune/trial.py b/python/ray/tune/trial.py index b4140ff04..0bcb04016 100644 --- a/python/ray/tune/trial.py +++ b/python/ray/tune/trial.py @@ -122,9 +122,15 @@ class Trial(object): try: if self.agent: - self.agent.stop.remote() - self.agent.__ray_terminate__.remote( - self.agent._ray_actor_id.id()) + stop_tasks = [] + stop_tasks.append(self.agent.stop.remote()) + stop_tasks.append(self.agent.__ray_terminate__.remote( + self.agent._ray_actor_id.id())) + _, unfinished = ray.wait( + stop_tasks, num_returns=2, timeout=10000) + if unfinished: + print(("Stopping %s Actor was unsuccessful, " + "but moving on...") % self) except Exception: print("Error stopping agent:", traceback.format_exc()) self.status = Trial.ERROR