Skip to content

Commit

Permalink
Moved imports in the Daemon class
Browse files Browse the repository at this point in the history
  • Loading branch information
bmeares committed Oct 11, 2021
1 parent 027a311 commit 1c587e5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions meerschaum/utils/daemon/Daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
"""
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 1c587e5

Please sign in to comment.