From 1f3c9af45be9a341ec4d54d2b9242865bb3fa16a Mon Sep 17 00:00:00 2001 From: mhchia Date: Wed, 4 Sep 2019 22:19:11 +0800 Subject: [PATCH] Add the missing `is_proc_running=True` --- tests/interop/daemon.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/interop/daemon.py b/tests/interop/daemon.py index e9c07e8..9735684 100644 --- a/tests/interop/daemon.py +++ b/tests/interop/daemon.py @@ -38,7 +38,7 @@ class P2PDProcess: proc: asyncio.subprocess.Process cmd: str = str(P2PD_PATH) args: List[Any] - is_running: bool + is_proc_running: bool _tasks: List["asyncio.Future[Any]"] @@ -71,7 +71,7 @@ class P2PDProcess: # - gossipsubHeartbeatInitialDelay: GossipSubHeartbeatInterval = 1 * time.Second # Referece: https://github.com/libp2p/go-libp2p-daemon/blob/b95e77dbfcd186ccf817f51e95f73f9fd5982600/p2pd/main.go#L348-L353 # noqa: E501 self.args = args - self.is_running = False + self.is_proc_running = False self._tasks = [] @@ -109,6 +109,8 @@ class P2PDProcess: await asyncio.sleep(0) async def start(self) -> None: + if self.is_proc_running: + return self.proc = await asyncio.subprocess.create_subprocess_exec( self.cmd, *self.args, @@ -116,14 +118,15 @@ class P2PDProcess: stderr=asyncio.subprocess.PIPE, bufsize=0, ) + self.is_proc_running = True await self.wait_until_ready() await self.start_printing_logs() async def close(self) -> None: - if self.is_running: + if self.is_proc_running: self.proc.terminate() await self.proc.wait() - self.is_running = False + self.is_proc_running = False for task in self._tasks: task.cancel()