|
1 | 1 | import asyncio
|
2 | 2 | import logging
|
3 | 3 | import os
|
| 4 | +import socket |
4 | 5 | import time
|
5 | 6 |
|
6 | 7 | import docker
|
@@ -86,7 +87,6 @@ def __init__(
|
86 | 87 | self.addr = config.participant["network_args"]["addr"]
|
87 | 88 | self.role = config.participant["device_args"]["role"]
|
88 | 89 | self.name = config.participant["device_args"]["name"]
|
89 |
| - self.docker_id = config.participant["device_args"]["docker_id"] |
90 | 90 | self.client = docker.from_env()
|
91 | 91 |
|
92 | 92 | print_banner()
|
@@ -601,22 +601,20 @@ async def _learning_cycle(self):
|
601 | 601 | if self.config.participant["scenario_args"]["controller"] != "nebula-test":
|
602 | 602 | result = await self.reporter.report_scenario_finished()
|
603 | 603 | if result:
|
604 |
| - pass |
| 604 | + logging.info("📝 Scenario finished reported succesfully") |
605 | 605 | else:
|
606 |
| - logging.error("Error reporting scenario finished") |
607 |
| - |
608 |
| - logging.info("Checking if all my connections reached the total rounds...") |
609 |
| - while not self.cm.check_finished_experiment(): |
610 |
| - await asyncio.sleep(1) |
| 606 | + logging.error("📝 Error reporting scenario finished") |
611 | 607 |
|
612 | 608 | await asyncio.sleep(5)
|
613 | 609 |
|
614 | 610 | # Kill itself
|
615 | 611 | if self.config.participant["scenario_args"]["deployment"] == "docker":
|
616 | 612 | try:
|
617 |
| - self.client.containers.get(self.docker_id).stop() |
| 613 | + docker_id = socket.gethostname() |
| 614 | + logging.info(f"📦 Killing docker container with ID {docker_id}") |
| 615 | + self.client.containers.get(docker_id).kill() |
618 | 616 | except Exception as e:
|
619 |
| - print(f"Error stopping Docker container with ID {self.docker_id}: {e}") |
| 617 | + logging.exception(f"📦 Error stopping Docker container with ID {docker_id}: {e}") |
620 | 618 |
|
621 | 619 | async def _extended_learning_cycle(self):
|
622 | 620 | """
|
|
0 commit comments