diff --git a/client-py3/full/linux/debian/control b/client-py3/full/linux/debian/control index f4dd4699..ba215dd9 100644 --- a/client-py3/full/linux/debian/control +++ b/client-py3/full/linux/debian/control @@ -10,6 +10,6 @@ Package: udsclient3 Section: admin Priority: optional Architecture: all -Depends: python3-paramiko (>=2.0.0), python2-certifi, python3-cryptography, python3-pyqt5 (>=5.0), python3 (>=3.6), freerdp2-x11 | freerdp-x11 | freerdp-nightly, desktop-file-utils, ${misc:Depends} +Depends: python3-paramiko (>=2.0.0), python2-certifi, python3-cryptography, python3-psutil, python3-pyqt5 (>=5.0), python3 (>=3.6), freerdp2-x11 | freerdp-x11 | freerdp-nightly, desktop-file-utils, ${misc:Depends} Description: Client connector for Universal Desktop Services (UDS) Broker This package provides the required components to allow this machine to connect to services provided by UDS Broker. diff --git a/client-py3/full/linux/udsclient-appimage-x86_64.recipe b/client-py3/full/linux/udsclient-appimage-x86_64.recipe index d922cf57..c2f498db 100644 --- a/client-py3/full/linux/udsclient-appimage-x86_64.recipe +++ b/client-py3/full/linux/udsclient-appimage-x86_64.recipe @@ -40,6 +40,7 @@ AppDir: - python3-paramiko - python3-cryptography - python3-certifi + - python3-psutil - freerdp2-x11 - freerdp2-wayland - x2goclient diff --git a/client-py3/full/linux/udsclient-template.spec b/client-py3/full/linux/udsclient-template.spec index 8171aeec..fef467f8 100644 --- a/client-py3/full/linux/udsclient-template.spec +++ b/client-py3/full/linux/udsclient-template.spec @@ -11,7 +11,7 @@ Release: %{release} Summary: Client for Universal Desktop Services (UDS) Broker License: BSD3 Group: Applications/Productivity -Requires: python3-paramiko python3-qt5 python3-cryptography python3-certifi +Requires: python3-paramiko python3-qt5 python3-cryptography python3-certifi python3-psutil Vendor: Virtual Cable S.L.U. URL: http://www.udsenterprise.com Provides: udsclient diff --git a/client-py3/full/src/uds/tools.py b/client-py3/full/src/uds/tools.py index d48e97ea..3c369b89 100644 --- a/client-py3/full/src/uds/tools.py +++ b/client-py3/full/src/uds/tools.py @@ -40,10 +40,15 @@ import time import base64 import typing +try: + import psutil +except ImportError: + psutil = None + from .log import logger _unlinkFiles: typing.List[str] = [] -_tasksToWait: typing.List[typing.Any] = [] +_tasksToWait: typing.List[typing.Tuple[typing.Any, bool]] = [] _execBeforeExit: typing.List[typing.Callable[[], None]] = [] sys_fs_enc = sys.getfilesystemencoding() or 'mbcs' @@ -147,17 +152,21 @@ def unlinkFiles() -> None: pass -def addTaskToWait(taks: typing.Any) -> None: +def addTaskToWait(taks: typing.Any, includeSubprocess: bool = False) -> None: _tasksToWait.append(taks) def waitForTasks() -> None: - for t in _tasksToWait: + for task, waitForSubp in _tasksToWait: try: - if hasattr(t, 'join'): - t.join() - elif hasattr(t, 'wait'): - t.wait() + if hasattr(task, 'join'): + task.join() + elif hasattr(task, 'wait'): + task.wait() + # If wait for spanwed process (look for process with task pid) and we can look for them... + if psutil and waitForSubp and hasattr(task, 'pid'): + for i in filter(lambda x: x.ppid() == task.pid, psutil.process_iter(attrs=('ppid',))): + i.wait() except Exception: pass