Saving debug info for proc and psutil processes which shows difference - psutil.process(pid) doesn't give register function

This commit is contained in:
David Murphy 2024-05-20 15:07:24 -06:00 committed by Daniel Wozniak
parent 01a44b41f8
commit 8198500f51
2 changed files with 36 additions and 1 deletions

View file

@ -528,11 +528,12 @@ class GitProvider:
if HAS_PSUTIL: if HAS_PSUTIL:
cur_pid = os.getpid() cur_pid = os.getpid()
process = psutil.Process(cur_pid) process = psutil.Process(cur_pid)
dgm_process_dir = dir(process)
log.warning( log.warning(
f"DGM class GitProvider dunder init, cur_pid '{cur_pid}', process '{process}'" f"DGM class GitProvider dunder init, cur_pid '{cur_pid}', process '{process}'"
) )
print( print(
f"DGM class GitProvider dunder init, cur_pid '{cur_pid}', process '{process}'" f"DGM class GitProvider dunder init, cur_pid '{cur_pid}', process '{process}', process dir '{dgm_process_dir}'"
) )
if isinstance(process, salt.utils.process.Process): if isinstance(process, salt.utils.process.Process):
cache_dir = self.opts.get("cachedir", None) cache_dir = self.opts.get("cachedir", None)

View file

@ -9,6 +9,7 @@ import pathlib
import signal import signal
import time import time
import psutil
import pytest import pytest
from saltfactories.utils import random_string from saltfactories.utils import random_string
@ -586,6 +587,39 @@ def test_git_provider_sigterm_cleanup(
) )
print(f"DGM test_git_provider_sigterm_cleanup, post add_process, proc '{proc}'") print(f"DGM test_git_provider_sigterm_cleanup, post add_process, proc '{proc}'")
print("DGM test area entry")
dgm_proc_dir = dir(proc)
print(
f"DGM test_git_provider_sigterm_cleanup, post add_process, proc '{proc}', proc dir '{dgm_proc_dir}'"
)
dgm_pid = proc.pid
print(f"DGM test_git_provider_sigterm_cleanup, proc pid '{proc.pid}'")
dgm_process = psutil.Process(dgm_pid)
print(f"DGM test_git_provider_sigterm_cleanup, psutil process '{dgm_process}'")
if isinstance(proc, salt.utils.process.Process):
print(
"DGM test_git_provider_sigterm_cleanup, proc isinstance salt utils process Process is TRUE"
)
else:
print(
"DGM test_git_provider_sigterm_cleanup, proc isinstance salt utils process Process is FALSE"
)
if isinstance(dgm_process, salt.utils.process.Process):
print(
"DGM test_git_provider_sigterm_cleanup, process isinstance salt utils process Process is TRUE"
)
else:
print(
"DGM test_git_provider_sigterm_cleanup, process isinstance salt utils process Process is FALSE"
)
print("DGM test area exit")
procmgr.run(asynchronous=True) procmgr.run(asynchronous=True)
time.sleep(2) # give some time for it to terminate time.sleep(2) # give some time for it to terminate