Skip to content

Commit 14f7a47

Browse files
committed
Fix bug in "blocking-until-connection" behaviour
1 parent ace077d commit 14f7a47

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

benchbot_api/benchbot.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ def __init__(self,
8080
self.supervisor_address = supervisor_address
8181
self._connection_callbacks = {}
8282

83-
self.set_agent(agent, auto_start)
83+
if auto_start:
84+
self.start()
85+
self.set_agent(agent)
8486

8587
def _build_address(self, route_name, route_type=RouteType.CONNECTION):
8688
"""Builds an address for communication with a running instance of
@@ -304,8 +306,10 @@ def run(self, agent=None):
304306
Generally, you should use this function and implement your object in
305307
your own custom agent class.
306308
"""
309+
print("SETTING AGENT")
307310
if agent is not None:
308311
self.set_agent(agent)
312+
print("SET AGENT")
309313
if self.agent is None:
310314
raise RuntimeError(
311315
"Can't call Benchbot.run() without an agent attached. Either "
@@ -329,7 +333,7 @@ def scene_fn():
329333
self.agent.save_result(self.result_filename, self.empty_results(),
330334
self.results_functions())
331335

332-
def set_agent(self, agent, auto_start=True):
336+
def set_agent(self, agent):
333337
"""Updates the current agent, and starts its connection with a BenchBot
334338
Supervisor if requested"""
335339
if agent is None:
@@ -341,8 +345,6 @@ def set_agent(self, agent, auto_start=True):
341345
"which is not an instance of '%s'." %
342346
(agent.__class__.__name__, Agent.__name__))
343347
self.agent = agent
344-
if auto_start:
345-
self.start()
346348

347349
def start(self):
348350
"""Establishes a connect to the Supervisor, and then uses this to

0 commit comments

Comments
 (0)