From 1c587e5dd547a66a212b70ffca985995cf528203 Mon Sep 17 00:00:00 2001 From: bmeares Date: Sun, 10 Oct 2021 23:56:54 -0700 Subject: [PATCH] Moved imports in the Daemon class --- meerschaum/utils/daemon/Daemon.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/meerschaum/utils/daemon/Daemon.py b/meerschaum/utils/daemon/Daemon.py index b51cea31..7f42759a 100644 --- a/meerschaum/utils/daemon/Daemon.py +++ b/meerschaum/utils/daemon/Daemon.py @@ -14,7 +14,6 @@ from meerschaum.utils.warnings import warn, error from meerschaum.utils.packages import attempt_import, venv_exec from meerschaum.utils.daemon._names import get_new_daemon_name -daemoniker, psutil = attempt_import('daemoniker', 'psutil') class Daemon: """ @@ -213,6 +212,7 @@ def kill(self, timeout : Optional[int] = 3) -> SuccessTuple: Forcibly terminate a running daemon. Sends a SIGTERM signal to the process. """ + daemoniker, psutil = attempt_import('daemoniker', 'psutil') success, msg = self._send_signal(daemoniker.SIGTERM, timeout=timeout) if success: return success, msg @@ -323,10 +323,11 @@ def mkdir_if_not_exists(self, allow_dirty_run : bool = False): ) @property - def process(self) -> Union[psutil.Process, None]: + def process(self) -> Union['psutil.Process', None]: """ Return the Process object from psutil. """ + psutil = attempt_import('psutil') pid = self.pid if pid is None: return None