Skip to content

Commit 7f016d5

Browse files
committed
Revert the addition of subprocess termination handling via Thread
because it can cause double subprocess communicate calls Signed-off-by: Min Lim <min.yeol.lim@intel.com>
1 parent 17191c2 commit 7f016d5

1 file changed

Lines changed: 2 additions & 12 deletions

File tree

gprofiler/utils/__init__.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
from pathlib import Path
3434
from subprocess import CompletedProcess, Popen, TimeoutExpired
3535
from tempfile import TemporaryDirectory
36-
from threading import Event, Thread
36+
from threading import Event
3737
from types import FrameType
3838
from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Union
3939

@@ -93,7 +93,6 @@ def start_process(
9393
cmd: Union[str, List[str]],
9494
via_staticx: bool = False,
9595
tmpdir: Optional[Path] = None,
96-
direct_call: bool = True,
9796
**kwargs: Any,
9897
) -> Popen:
9998
if isinstance(cmd, str):
@@ -137,15 +136,6 @@ def start_process(
137136
**kwargs,
138137
)
139138

140-
def process_exit_handler() -> None:
141-
process.communicate()
142-
# Remove from _processes and do any cleanup
143-
cleanup_process_reference(process)
144-
logger.critical(f"Process {process.pid} exited, total processes tracked {len(_processes)}")
145-
146-
_processes.append(process)
147-
if direct_call:
148-
Thread(target=process_exit_handler, daemon=True).start()
149139
return process
150140

151141

@@ -230,7 +220,7 @@ def run_process(
230220
stderr: bytes
231221

232222
reraise_exc: Optional[BaseException] = None
233-
with start_process(cmd, via_staticx, direct_call=False, **kwargs) as process:
223+
with start_process(cmd, via_staticx, **kwargs) as process:
234224
assert isinstance(process.args, str) or (
235225
isinstance(process.args, list) and all(isinstance(s, str) for s in process.args)
236226
), process.args # mypy

0 commit comments

Comments
 (0)