Removed debugging statements

This commit is contained in:
David Murphy 2024-05-22 13:32:54 -06:00 committed by Daniel Wozniak
parent 9bb92ed23d
commit 332379d06a
3 changed files with 26 additions and 315 deletions

View file

@ -251,15 +251,13 @@ class GitProvider:
override_params, override_params,
cache_root, cache_root,
role="gitfs", role="gitfs",
): # pylint: disable=logging-fstring-interpolation ):
self.opts = opts self.opts = opts
self.role = role self.role = role
def _val_cb(x, y): def _val_cb(x, y):
return str(y) return str(y)
## DGM print(f"DGM class GitProvider dunder init, opts '{opts}'", flush=True)
# get machine_identifier # get machine_identifier
self.mach_id = _get_machine_identifier().get( self.mach_id = _get_machine_identifier().get(
"machine_id", "no_machine_id_available" "machine_id", "no_machine_id_available"
@ -531,32 +529,11 @@ class GitProvider:
cur_pid = os.getpid() cur_pid = os.getpid()
process = psutil.Process(cur_pid) process = psutil.Process(cur_pid)
dgm_process_dir = dir(process) dgm_process_dir = dir(process)
log.warning(
f"DGM class GitProvider dunder init, cur_pid '{cur_pid}', process '{process}'"
)
print(
f"DGM class GitProvider dunder init, cur_pid '{cur_pid}', process '{process}', process dir '{dgm_process_dir}'",
flush=True,
)
cache_dir = self.opts.get("cachedir", None) cache_dir = self.opts.get("cachedir", None)
gitfs_active = self.opts.get("gitfs_remotes", None) gitfs_active = self.opts.get("gitfs_remotes", None)
log.warning(
f"DGM class GitProvider dunder init, cache_dir '{cache_dir}', gitfs_active '{gitfs_active}'"
)
print(
f"DGM class GitProvider dunder init, cache_dir '{cache_dir}', gitfs_active '{gitfs_active}'",
flush=True,
)
if cache_dir and gitfs_active: if cache_dir and gitfs_active:
log.warning( salt.utils.process.register_cleanup_finalize_function(
f"DGM class GitProvider registering gitfs_zombie_cleanup with cache_dir '{cache_dir}'" gitfs_finalize_cleanup, cache_dir
)
print(
f"DGM class GitProvider registering gitfs_zombie_cleanup with cache_dir '{cache_dir}'",
flush=True,
)
salt.utils.process.register_cleanup_zombie_function(
gitfs_zombie_cleanup, cache_dir
) )
def get_cache_basehash(self): def get_cache_basehash(self):
@ -3676,27 +3653,12 @@ class WinRepo(GitBase):
self.winrepo_dirs[repo.id] = cachedir self.winrepo_dirs[repo.id] = cachedir
## DGM wip code def gitfs_finalize_cleanup(cache_dir):
# pylint: disable=logging-fstring-interpolation
def gitfs_zombie_cleanup(cache_dir):
""" """
Clean up zombie processes that used gitfs Clean up finalize processes that used gitfs
Initial wip
""" """
log.warning(
f"DGM class GitProvider gitfs_zombie_cleanup entry, cache_dir '{cache_dir}'"
)
print(
f"DGM class GitProvider gitfs_zombie_cleanup entry, cache_dir '{cache_dir}'",
flush=True,
)
cur_pid = os.getpid() cur_pid = os.getpid()
mach_id = _get_machine_identifier().get("machine_id", "no_machine_id_available") mach_id = _get_machine_identifier().get("machine_id", "no_machine_id_available")
log.debug("exiting for process id %s and machine identifer %s", cur_pid, mach_id)
print(
f"DGM exiting for process id '{cur_pid}' and machine identifer '{mach_id}'",
flush=True,
)
# need to clean up any resources left around like lock files if using gitfs # need to clean up any resources left around like lock files if using gitfs
# example: lockfile # example: lockfile

View file

@ -30,10 +30,6 @@ import salt.utils.versions
from salt.ext.tornado import gen from salt.ext.tornado import gen
from salt.utils.platform import get_machine_identifier as _get_machine_identifier from salt.utils.platform import get_machine_identifier as _get_machine_identifier
## DGM import pathlib
## DGM import shutil
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
HAS_PSUTIL = False HAS_PSUTIL = False
@ -51,8 +47,8 @@ try:
except ImportError: except ImportError:
HAS_SETPROCTITLE = False HAS_SETPROCTITLE = False
## DGM # Process finalization function list
_INTERNAL_PROCESS_ZOMBIE_LIST = [] _INTERNAL_PROCESS_FINALIZE_FUNCTION_LIST = []
def appendproctitle(name): def appendproctitle(name):
@ -533,8 +529,7 @@ class ProcessManager:
target=tgt, args=args, kwargs=kwargs, name=name or tgt.__qualname__ target=tgt, args=args, kwargs=kwargs, name=name or tgt.__qualname__
) )
## DGM try cleaning up call process.register_finalize_method(cleanup_finalize_process, args, kwargs)
process.register_finalize_method(cleanup_zombie_process, args, kwargs)
if isinstance(process, SignalHandlingProcess): if isinstance(process, SignalHandlingProcess):
with default_signals(signal.SIGINT, signal.SIGTERM): with default_signals(signal.SIGINT, signal.SIGTERM):
@ -690,7 +685,6 @@ class ProcessManager:
else: else:
for pid, p_map in self._process_map.copy().items(): for pid, p_map in self._process_map.copy().items():
log.trace("Terminating pid %s: %s", pid, p_map["Process"]) log.trace("Terminating pid %s: %s", pid, p_map["Process"])
print("Terminating pid %s: %s", pid, p_map["Process"])
if args: if args:
# escalate the signal to the process # escalate the signal to the process
try: try:
@ -713,11 +707,9 @@ class ProcessManager:
end_time = time.time() + self.wait_for_kill # when to die end_time = time.time() + self.wait_for_kill # when to die
log.trace("Waiting to kill process manager children") log.trace("Waiting to kill process manager children")
print("Waiting to kill process manager children")
while self._process_map and time.time() < end_time: while self._process_map and time.time() < end_time:
for pid, p_map in self._process_map.copy().items(): for pid, p_map in self._process_map.copy().items():
log.trace("Joining pid %s: %s", pid, p_map["Process"]) log.trace("Joining pid %s: %s", pid, p_map["Process"])
print("Joining pid %s: %s", pid, p_map["Process"])
p_map["Process"].join(0) p_map["Process"].join(0)
if not p_map["Process"].is_alive(): if not p_map["Process"].is_alive():
@ -766,15 +758,7 @@ class ProcessManager:
for (k, v) in self._process_map.items() for (k, v) in self._process_map.items()
), ),
) )
print(
"Some processes failed to respect the KILL signal: %s",
"; ".join(
"Process: {} (Pid: {})".format(v["Process"], k)
for (k, v) in self._process_map.items()
),
)
log.info("kill_children retries left: %s", available_retries) log.info("kill_children retries left: %s", available_retries)
print("kill_children retries left: %s", available_retries)
kwargs["retry"] = available_retries - 1 kwargs["retry"] = available_retries - 1
return self.kill_children(*args, **kwargs) return self.kill_children(*args, **kwargs)
else: else:
@ -788,34 +772,18 @@ class ProcessManager:
) in self._process_map.items() ) in self._process_map.items()
), ),
) )
print(
"Failed to kill the following processes: %s",
"; ".join(
"Process: {} (Pid: {})".format(v["Process"], k)
for (
k,
v,
) in self._process_map.items()
),
)
log.warning( log.warning(
"Salt will either fail to terminate now or leave some " "Salt will either fail to terminate now or leave some "
"zombie processes behind" "zombie processes behind"
) )
print(
"Salt will either fail to terminate now or leave some "
"zombie processes behind"
)
def terminate(self): def terminate(self):
""" """
Properly terminate this process manager instance Properly terminate this process manager instance
""" """
print("DGM class ProcessManager terminate entry", flush=True)
self.stop_restarting() self.stop_restarting()
self.send_signal_to_processes(signal.SIGTERM) self.send_signal_to_processes(signal.SIGTERM)
self.kill_children() self.kill_children()
print("DGM class ProcessManager terminate exit", flush=True)
def _handle_signals(self, *args, **kwargs): def _handle_signals(self, *args, **kwargs):
# first lets reset signal handlers to default one to prevent running this twice # first lets reset signal handlers to default one to prevent running this twice
@ -1051,14 +1019,6 @@ class Process(multiprocessing.Process):
# Run any registered process finalization routines # Run any registered process finalization routines
try: try:
for method, args, kwargs in self._finalize_methods: for method, args, kwargs in self._finalize_methods:
# pylint: disable=logging-fstring-interpolation
log.warning(
f"DGM class Process wrapped_run_func, method '{method}', args '{args}', kwargs '{kwargs}'"
)
print(
f"DGM class Process wrapped_run_func, method '{method}', args '{args}', kwargs '{kwargs}'",
flush=True,
)
try: try:
method(*args, **kwargs) method(*args, **kwargs)
except Exception: # pylint: disable=broad-except except Exception: # pylint: disable=broad-except
@ -1091,23 +1051,8 @@ class Process(multiprocessing.Process):
""" """
Register a function to run as process terminates Register a function to run as process terminates
""" """
# pylint: disable=logging-fstring-interpolation
log.warning(
f"DGM class Process register_finalize_method entry, function '{function}', args '{args}', kwargs '{kwargs}'"
)
print(
f"DGM class Process register_finalize_method entry, function '{function}', args '{args}', kwargs '{kwargs}'",
flush=True,
)
finalize_method_tuple = (function, args, kwargs) finalize_method_tuple = (function, args, kwargs)
if finalize_method_tuple not in self._finalize_methods: if finalize_method_tuple not in self._finalize_methods:
log.warning(
f"DGM register_finalize_method, appending tuple finalize_method_tuple '{finalize_method_tuple}'"
)
print(
f"DGM register_finalize_method, appending tuple finalize_method_tuple '{finalize_method_tuple}'",
flush=True,
)
self._finalize_methods.append(finalize_method_tuple) self._finalize_methods.append(finalize_method_tuple)
@ -1134,28 +1079,8 @@ class SignalHandlingProcess(Process):
msg += ". Exiting" msg += ". Exiting"
log.debug(msg) log.debug(msg)
print(f"DGM class SignalHandlingProcess, _handle_signals {msg}", flush=True)
## DGM mach_id = _get_machine_identifier().get("machine_id", "no_machine_id_available")
## DGM log.debug(
## DGM "exiting for process id %s and machine identifer %s", os.getpid(), mach_id
## DGM )
## DGM
## DGM cur_pid = os.getpid()
# Run any registered process finalization routines # Run any registered process finalization routines
print(
"DGM class SignalHandlingProcess, attempt to print out _finalize_methods",
flush=True,
)
for method, args, kwargs in self._finalize_methods: for method, args, kwargs in self._finalize_methods:
# pylint: disable=logging-fstring-interpolation
log.warning(
f"DGM class SignalHandlingProcess, method '{method}', args '{args}', kwargs '{kwargs}'"
)
print(
f"DGM class SignalHandlingProcess, method '{method}', args '{args}', kwargs '{kwargs}', flush=True"
)
try: try:
method(*args, **kwargs) method(*args, **kwargs)
except Exception: # pylint: disable=broad-except except Exception: # pylint: disable=broad-except
@ -1168,11 +1093,6 @@ class SignalHandlingProcess(Process):
) )
continue continue
print(
"DGM class SignalHandlingProcess, done to print out _finalize_methods",
flush=True,
)
if HAS_PSUTIL: if HAS_PSUTIL:
try: try:
process = psutil.Process(os.getpid()) process = psutil.Process(os.getpid())
@ -1189,106 +1109,6 @@ class SignalHandlingProcess(Process):
os.getpid(), os.getpid(),
) )
## DGM # need to clean up any resources left around like lock files if using gitfs
## DGM # example: lockfile i
## DGM # /var/cache/salt/master/gitfs/work/NlJQs6Pss_07AugikCrmqfmqEFrfPbCDBqGLBiCd3oU=/_/update.lk
## DGM cache_dir = self.opts.get("cachedir", None)
## DGM gitfs_active = self.opts.get("gitfs_remotes", None)
## DGM if cache_dir and gitfs_active:
## DGM # check for gitfs file locks to ensure no resource leaks
## DGM # last chance to clean up any missed unlock droppings
## DGM cache_dir = pathlib.Path(cache_dir + "/gitfs/work")
## DGM if cache_dir.exists and cache_dir.is_dir():
## DGM file_list = list(cache_dir.glob("**/*.lk"))
## DGM file_del_list = []
## DGM file_pid = 0
## DGM file_mach_id = 0
## DGM try:
## DGM for file_name in file_list:
## DGM with salt.utils.files.fopen(file_name, "r") as fd_:
## DGM try:
## DGM file_pid = int(
## DGM salt.utils.stringutils.to_unicode(
## DGM fd_.readline()
## DGM ).rstrip()
## DGM )
## DGM except ValueError:
## DGM # Lock file is empty, set pid to 0 so it evaluates as False.
## DGM file_pid = 0
## DGM try:
## DGM file_mach_id = (
## DGM salt.utils.stringutils.to_unicode(
## DGM fd_.readline()
## DGM ).rstrip()
## DGM )
## DGM except ValueError:
## DGM # Lock file is empty, set mach_id to 0 so it evaluates False.
## DGM file_mach_id = 0
## DGM if cur_pid == file_pid:
## DGM if mach_id != file_mach_id:
## DGM if not file_mach_id:
## DGM msg = (
## DGM f"gitfs lock file for pid '{file_pid}' does not "
## DGM "contain a machine id, deleting lock file which may "
## DGM "affect if using multi-master with shared gitfs cache, "
## DGM "the lock may have been obtained by another master "
## DGM "recommend updating Salt version on other masters to a "
## DGM "version which insert machine identification in lock a file."
## DGM )
## DGM log.debug(msg)
## DGM file_del_list.append(
## DGM (file_name, file_pid, file_mach_id)
## DGM )
## DGM else:
## DGM file_del_list.append(
## DGM (file_name, file_pid, file_mach_id)
## DGM )
## DGM except FileNotFoundError:
## DGM log.debug("gitfs lock file: %s not found", file_name)
## DGM for file_name, file_pid, file_mach_id in file_del_list:
## DGM try:
## DGM os.remove(file_name)
## DGM except OSError as exc:
## DGM if exc.errno == errno.ENOENT:
## DGM # No lock file present
## DGM msg = (
## DGM "SIGTERM clean up of resources attempted to remove lock "
## DGM f"file {file_name}, pid '{file_pid}', machine identifier "
## DGM f"'{mach_id}' but it did not exist, exception : {exc} "
## DGM )
## DGM log.debug(msg)
## DGM elif exc.errno == errno.EISDIR:
## DGM # Somehow this path is a directory. Should never happen
## DGM # unless some wiseguy manually creates a directory at this
## DGM # path, but just in case, handle it.
## DGM try:
## DGM shutil.rmtree(file_name)
## DGM except OSError as exc:
## DGM msg = (
## DGM f"SIGTERM clean up of resources, lock file '{file_name}'"
## DGM f", pid '{file_pid}', machine identifier '{file_mach_id}'"
## DGM f"was a directory, removed directory, exception : '{exc}'"
## DGM )
## DGM log.debug(msg)
## DGM else:
## DGM msg = (
## DGM "SIGTERM clean up of resources, unable to remove lock file "
## DGM f"'{file_name}', pid '{file_pid}', machine identifier "
## DGM f"'{file_mach_id}', exception : '{exc}'"
## DGM )
## DGM log.debug(msg)
## DGM else:
## DGM msg = (
## DGM "SIGTERM clean up of resources, removed lock file "
## DGM f"'{file_name}', pid '{file_pid}', machine identifier "
## DGM f"'{file_mach_id}'"
## DGM )
## DGM log.debug(msg)
except psutil.NoSuchProcess: except psutil.NoSuchProcess:
log.warning( log.warning(
"Unable to kill children of process %d, it does not exist." "Unable to kill children of process %d, it does not exist."
@ -1362,7 +1182,7 @@ class SubprocessList:
log.debug("Subprocess %s cleaned up", proc.name) log.debug("Subprocess %s cleaned up", proc.name)
def cleanup_zombie_process(*args, **kwargs): def cleanup_finalize_process(*args, **kwargs):
""" """
Generic process to allow for any registered process cleanup routines to execute. Generic process to allow for any registered process cleanup routines to execute.
@ -1373,17 +1193,13 @@ def cleanup_zombie_process(*args, **kwargs):
which cannot be added by the register_finalize_method. which cannot be added by the register_finalize_method.
""" """
print("\nDGM cleanup_zombie_process entry\n", flush=True) # Run any registered process cleanup routines
for method, args, kwargs in _INTERNAL_PROCESS_FINALIZE_FUNCTION_LIST:
# Run any register process cleanup routines log.debug(
for method, args, kwargs in _INTERNAL_PROCESS_ZOMBIE_LIST: "cleanup_finalize_process, method=%r, args=%r, kwargs=%r",
# pylint: disable=logging-fstring-interpolation method,
log.warning( args,
f"DGM cleanup_zombie_process, method '{method}', args '{args}', kwargs '{kwargs}'" kwargs,
)
print(
f"DGM cleanup_zombie_process, method '{method}', args '{args}', kwargs '{kwargs}'",
flush=True,
) )
try: try:
method(*args, **kwargs) method(*args, **kwargs)
@ -1396,10 +1212,8 @@ def cleanup_zombie_process(*args, **kwargs):
) )
continue continue
print("\nDGM cleanup_zombie_process exit\n", flush=True)
def register_cleanup_finalize_function(function, *args, **kwargs):
def register_cleanup_zombie_function(function, *args, **kwargs):
""" """
Register a function to run as process terminates Register a function to run as process terminates
@ -1407,25 +1221,16 @@ def register_cleanup_zombie_function(function, *args, **kwargs):
using psutil.Process, there is no method available to register a cleanup process. using psutil.Process, there is no method available to register a cleanup process.
Hence, this function can be used to register a function to allow cleanup processes Hence, this function can be used to register a function to allow cleanup processes
which cannot be added by the register_finalize_method. which cannot be added by class Process register_finalize_method.
Note: there is no deletion, since it is assummed that if something is registered, it will continue to be used Note: there is no deletion, since it is assummed that if something is registered, it will continue to be used
""" """
# pylint: disable=logging-fstring-interpolation log.debug(
log.warning( "register_cleanup_finalize_function entry, function=%r, args=%r, kwargs=%r",
f"DGM register_cleanup_zombie_function entry, function '{function}', args '{args}', kwargs '{kwargs}'" function,
) args,
print( kwargs,
f"DGM register_cleanup_zombie_function entry, function '{function}', args '{args}', kwargs '{kwargs}'",
flush=True,
) )
finalize_function_tuple = (function, args, kwargs) finalize_function_tuple = (function, args, kwargs)
if finalize_function_tuple not in _INTERNAL_PROCESS_ZOMBIE_LIST: if finalize_function_tuple not in _INTERNAL_PROCESS_FINALIZE_FUNCTION_LIST:
log.warning( _INTERNAL_PROCESS_FINALIZE_FUNCTION_LIST.append(finalize_function_tuple)
f"DGM register_cleanup_zombie_function, appending tuple finalize_function_tuple '{finalize_function_tuple}'"
)
print(
f"DGM register_cleanup_zombie_function, appending tuple finalize_function_tuple '{finalize_function_tuple}'",
flush=True,
)
_INTERNAL_PROCESS_ZOMBIE_LIST.append(finalize_function_tuple)

View file

@ -9,7 +9,6 @@ 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
@ -553,7 +552,6 @@ class KillProcessTest(salt.utils.process.SignalHandlingProcess):
log.debug("KillProcessTest acquried lock file %s", lockfile) log.debug("KillProcessTest acquried lock file %s", lockfile)
killtest_pid = os.getpid() killtest_pid = os.getpid()
print(f"KillProcessTest pid '{killtest_pid}', acquried lock file '{lockfile}'")
# check that lock has been released # check that lock has been released
assert self.provider._master_lock.acquire(timeout=5) assert self.provider._master_lock.acquire(timeout=5)
@ -566,16 +564,11 @@ class KillProcessTest(salt.utils.process.SignalHandlingProcess):
@pytest.mark.slow_test @pytest.mark.slow_test
@pytest.mark.skip_unless_on_linux @pytest.mark.skip_unless_on_linux
@pytest.mark.timeout_unless_on_windows(120) @pytest.mark.timeout_unless_on_windows(120)
def test_git_provider_sigterm_cleanup( def test_git_provider_sigterm_cleanup(main_class):
main_class,
): # pylint: disable=logging-fstring-interpolation
""" """
Start process which will obtain lock, and leave it locked Start process which will obtain lock, and leave it locked
then kill the process via SIGTERM and ensure locked resources are cleaned up then kill the process via SIGTERM and ensure locked resources are cleaned up
""" """
log.warning("DGM test_git_provider_sigterm_cleanup entry")
print("DGM test_git_provider_sigterm_cleanup entry", flush=True)
provider = main_class.remotes[0] provider = main_class.remotes[0]
with salt.utils.process.default_signals(signal.SIGINT, signal.SIGTERM): with salt.utils.process.default_signals(signal.SIGINT, signal.SIGTERM):
@ -585,49 +578,6 @@ def test_git_provider_sigterm_cleanup(
while not proc.is_alive(): while not proc.is_alive():
time.sleep(1) # give some time for it to be started time.sleep(1) # give some time for it to be started
log.warning(
f"DGM test_git_provider_sigterm_cleanup, post add_process, proc '{proc}'"
)
## DGM print("DGM test area entry\n\n\n\n", flush=True)
## DGM dgm_proc_dir = dir(proc)
## DGM print(f"DGM test_git_provider_sigterm_cleanup, post add_process, proc '{proc}', proc dir '{dgm_proc_dir}'", flush=True)
## DGM dgm_pid = proc.pid
## DGM print(f"DGM test_git_provider_sigterm_cleanup, proc pid '{proc.pid}'", flush=True)
## DGM dgm_process = psutil.Process(dgm_pid)
## DGM print(f"DGM test_git_provider_sigterm_cleanup, psutil process '{dgm_process}'", flush=True)
## DGM dgm_process_dir = dir(dgm_process)
## DGM print(f"DGM test_git_provider_sigterm_cleanup, psutil process '{dgm_process}', process dir '{dgm_process_dir}'", flush=True)
## DGM ## DGM print(f"DGM test_git_provider_sigterm_cleanup, checking values psutil process '{dgm_process}', pid '{dgm_process.pid}', name '{dgm_process.name()}', username '{dgm_process.username()}', as_dict '{dgm_process.as_dict()}', cmdline '{dgm_process.cmdline()}'", flush=True)
## DGM print(f"DGM test_git_provider_sigterm_cleanup, checking values psutil process '{dgm_process}', pid '{dgm_process.pid}', ppid '{dgm_process.ppid}', name '{dgm_process.name()}', username '{dgm_process.username()}', cmdline '{dgm_process.cmdline()}'", flush=True)
## DGM dgm_dict = dgm_process.as_dict()
## DGM dgm_process_parent_pid = dgm_dict["ppid"]
## DGM dgm_process_parent = psutil.Process(dgm_process_parent_pid)
## DGM dgm_process_parent_dir = dir(dgm_process_parent)
## DGM print(f"DGM test_git_provider_sigterm_cleanup, parent pid '{dgm_process_parent_pid}' psutil process '{dgm_process_parent}', name '{dgm_process_parent.name()}', cmdline '{dgm_process_parent.cmdline()}', dir '{dgm_process_parent_dir}'", flush=True)
## DGM if isinstance(proc, salt.utils.process.Process):
## DGM print("DGM test_git_provider_sigterm_cleanup, proc isinstance salt utils process Process is TRUE", flush=True)
## DGM else:
## DGM print("DGM test_git_provider_sigterm_cleanup, proc isinstance salt utils process Process is FALSE", flush=True)
## DGM if isinstance(dgm_process, salt.utils.process.Process):
## DGM print("DGM test_git_provider_sigterm_cleanup, process isinstance salt utils process Process is TRUE", flush=True)
## DGM else:
## DGM print("DGM test_git_provider_sigterm_cleanup, process isinstance salt utils process Process is FALSE", flush=True)
## DGM if isinstance(dgm_process_parent, salt.utils.process.ProcessManager):
## DGM print("DGM test_git_provider_sigterm_cleanup, process isinstance salt utils process ProcessManager is TRUE", flush=True)
## DGM else:
## DGM print("DGM test_git_provider_sigterm_cleanup, process isinstance salt utils process ProcessManager is FALSE", flush=True)
## DGM print("DGM test area exit\n\n\n\n", flush=True)
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
@ -635,18 +585,12 @@ def test_git_provider_sigterm_cleanup(
# child process should be alive # child process should be alive
file_name = provider._get_lock_file("update") file_name = provider._get_lock_file("update")
log.warning(f"DGM test_git_provider_sigterm_cleanup, file_name '{file_name}'")
print(f"DGM test_git_provider_sigterm_cleanup, file_name '{file_name}'", flush=True)
assert pathlib.Path(file_name).exists() assert pathlib.Path(file_name).exists()
assert pathlib.Path(file_name).is_file() assert pathlib.Path(file_name).is_file()
print("DGM test_git_provider_sigterm_cleanup, terminate procmgr start", flush=True)
procmgr.terminate() # sends a SIGTERM procmgr.terminate() # sends a SIGTERM
time.sleep(2) # give some time for it to terminate time.sleep(2) # give some time for it to terminate
print("DGM test_git_provider_sigterm_cleanup, terminate procmgr exit", flush=True)
assert not proc.is_alive() assert not proc.is_alive()
assert not pathlib.Path(file_name).exists() assert not pathlib.Path(file_name).exists()