Skip to content

Commit

Permalink
[releases/1.2] Fix the discovery service to not terminate on parent p…
Browse files Browse the repository at this point in the history
…rocess closure (#391)

* Add DETACHED_PROCESS flag to detach the discovery process from its parent console process

* Fix test failure

---------

Co-authored-by: Joel Dixon <[email protected]>
  • Loading branch information
samchris007 and dixonjoel authored Sep 21, 2023
1 parent a9d542d commit 8656f5a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ni_measurementlink_service/_internal/discovery_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def _start_service(
kwargs: Dict[str, Any] = {}
if sys.platform == "win32":
# Terminating the measurement service should not terminate the discovery service.
kwargs["creationflags"] = subprocess.CREATE_BREAKAWAY_FROM_JOB
kwargs["creationflags"] = subprocess.CREATE_BREAKAWAY_FROM_JOB | subprocess.DETACHED_PROCESS
discovery_service_subprocess = subprocess.Popen(
[exe_file_path],
cwd=exe_file_path.parent,
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_discovery_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def test___discovery_service_exe_unavailable___register_service___raises_file_no
def subprocess_popen_kwargs() -> Dict[str, Any]:
kwargs: Dict[str, Any] = {}
if sys.platform == "win32":
kwargs["creationflags"] = subprocess.CREATE_BREAKAWAY_FROM_JOB
kwargs["creationflags"] = subprocess.CREATE_BREAKAWAY_FROM_JOB | subprocess.DETACHED_PROCESS
return kwargs


Expand Down

0 comments on commit 8656f5a

Please sign in to comment.