Skip to content

Commit 525618d

Browse files
Merge pull request #313 from pollen-robotics/312-daemon-publish-thread-prevents-from-running-start-multiple-times
Fix publish thread restart when multiple start/stop
2 parents 937867d + b8ff0d8 commit 525618d

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/reachy_mini/daemon/daemon.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ def __init__(self, log_level: str = "INFO", wireless_version: bool = False) -> N
4848
error=None,
4949
wlan_ip=None,
5050
)
51-
self._thread_publish_status = Thread(target=self._publish_status, daemon=True)
5251
self._thread_event_publish_status = Event()
5352

5453
async def start(
@@ -115,6 +114,8 @@ async def start(
115114

116115
self.server = ZenohServer(self.backend, localhost_only=localhost_only)
117116
self.server.start()
117+
118+
self._thread_publish_status = Thread(target=self._publish_status, daemon=True)
118119
self._thread_publish_status.start()
119120

120121
def backend_wrapped_run() -> None:

tests/test_daemon.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,19 @@ async def test_daemon_start_stop() -> None:
1818
await daemon.stop(goto_sleep_on_stop=False)
1919

2020

21+
@pytest.mark.asyncio
22+
async def test_daemon_multiple_start_stop() -> None:
23+
daemon = Daemon()
24+
25+
for _ in range(3):
26+
await daemon.start(
27+
sim=True,
28+
headless=True,
29+
wake_up_on_start=False,
30+
)
31+
await daemon.stop(goto_sleep_on_stop=False)
32+
33+
2134
@pytest.mark.asyncio
2235
async def test_daemon_client_disconnection() -> None:
2336
daemon = Daemon()

0 commit comments

Comments
 (0)