From 75cc2e46e68006217c1c2e17b0901923e9e69fe2 Mon Sep 17 00:00:00 2001 From: boeckwi Date: Tue, 26 Aug 2025 09:43:08 +0200 Subject: [PATCH 1/2] fixed windows wmic result parsing --- luigi/lock.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/luigi/lock.py b/luigi/lock.py index 5a9e1f8014..5b5b0a311b 100644 --- a/luigi/lock.py +++ b/luigi/lock.py @@ -39,7 +39,7 @@ def getpcmd(pid): with os.popen(cmd, 'r') as p: lines = [line for line in p.readlines() if line.strip("\r\n ") != ""] if lines: - _, val = lines + val = lines[-1] return val elif sys.platform == "darwin": # Use pgrep instead of /proc on macOS. From 8dfd42ed0004c4c958e9fe7ffce850f710a307d5 Mon Sep 17 00:00:00 2001 From: boeckwi Date: Wed, 27 Aug 2025 08:26:58 +0200 Subject: [PATCH 2/2] changed wmic to powershell --- luigi/lock.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/luigi/lock.py b/luigi/lock.py index 5b5b0a311b..402b67cb46 100644 --- a/luigi/lock.py +++ b/luigi/lock.py @@ -34,8 +34,10 @@ def getpcmd(pid): :param pid: """ if os.name == "nt": - # Use wmic command instead of ps on Windows. - cmd = 'wmic path win32_process where ProcessID=%s get Commandline 2> nul' % (pid, ) + # Use powershell command instead of ps on Windows. + pcmd = (f"Get-CimInstance Win32_Process -Filter 'ProcessId={pid}' | " + "Select-Object CommandLine") + cmd = f'powershell.exe -Command "{pcmd}"' with os.popen(cmd, 'r') as p: lines = [line for line in p.readlines() if line.strip("\r\n ") != ""] if lines: