Skip to content

Commit 8a7d523

Browse files
authored
Merge pull request #89 from adf-python/fix/connect
接続時のログを見やすくした
2 parents 30600ae + 947da28 commit 8a7d523

File tree

11 files changed

+8
-15
lines changed

11 files changed

+8
-15
lines changed

adf_core_python/core/agent/agent.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ def handle_connect_error(self, msg: Any) -> NoReturn:
238238
msg.reason,
239239
msg.request_id,
240240
)
241+
self.finish_post_connect_event.set()
241242
else:
242243
self.logger.error(
243244
"Failed to connect agent: %s(request_id: %s)",
@@ -264,10 +265,16 @@ def handle_connect_ok(self, msg: Any) -> None:
264265
self.config.set_value(key, value)
265266
self.send_acknowledge(msg.request_id)
266267
self.post_connect()
268+
self.logger.info(
269+
f"Connected to kernel: {self.__class__.__qualname__} (request_id: {msg.request_id})",
270+
request_id=msg.request_id,
271+
)
267272
if self.precompute_flag:
268273
print("self.precompute_flag: ", self.precompute_flag)
269274
self.precompute()
270275

276+
self.finish_post_connect_event.set()
277+
271278
def handler_sense(self, msg: Any) -> None:
272279
_id = EntityID(msg.agent_id)
273280
time = msg.time

adf_core_python/core/agent/office/office.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ def post_connect(self) -> None:
9494
self.precompute_data,
9595
self._develop_data,
9696
)
97-
self.finish_post_connect_event.set()
9897

9998
def think(self) -> None:
10099
self._tactics_center.think(

adf_core_python/core/agent/platoon/platoon.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,6 @@ def post_connect(self) -> None:
9696
self._develop_data,
9797
)
9898

99-
self.finish_post_connect_event.set()
100-
10199
def think(self) -> None:
102100
action: Action = self._tactics_agent.think(
103101
self._agent_info,

adf_core_python/core/launcher/agent_launcher.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,7 @@ def connect() -> None:
7272
for thread, event in threads.items():
7373
thread.daemon = True
7474
thread.start()
75-
is_not_timeout = event.wait(5)
76-
if not is_not_timeout:
77-
break
75+
event.wait(5)
7876

7977
connector_thread = threading.Thread(target=connect)
8078
connector_thread_list.append(connector_thread)

adf_core_python/core/launcher/connect/component_launcher.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ def make_connection(self) -> Connection:
1717
return Connection(self.host, self.port)
1818

1919
def connect(self, agent: Agent, _request_id: int) -> None:
20-
self.logger.info(
21-
f"{agent.__class__.__name__} trying to connect to {self.host}:{self.port} request_id: {_request_id}"
22-
)
2320
connection = self.make_connection()
2421
try:
2522
connection.connect()

adf_core_python/core/launcher/connect/connector_ambulance_center.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,4 @@ def connect(
7474
)
7575
threads[thread] = finish_post_connect_event
7676

77-
self.logger.info("Connected ambulance center (count: %d)" % count)
7877
return threads

adf_core_python/core/launcher/connect/connector_ambulance_team.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,4 @@ def connect(
7474
)
7575
threads[thread] = finish_post_connect_event
7676

77-
self.logger.info("Connected ambulance team (count: %d)" % count)
7877
return threads

adf_core_python/core/launcher/connect/connector_fire_brigade.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,4 @@ def connect(
7272
)
7373
threads[thread] = finish_post_connect_event
7474

75-
self.logger.info("Connected fire brigade (count: %d)" % count)
7675
return threads

adf_core_python/core/launcher/connect/connector_fire_station.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,4 @@ def connect(
7272
)
7373
threads[thread] = finish_post_connect_event
7474

75-
self.logger.info("Connected fire station (count: %d)" % count)
7675
return threads

adf_core_python/core/launcher/connect/connector_police_force.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,4 @@ def connect(
7272
)
7373
threads[thread] = finish_post_connect_event
7474

75-
self.logger.info("Connected police force (count: %d)" % count)
7675
return threads

0 commit comments

Comments
 (0)