This commit is contained in:
Shreyas Goenka 2025-02-28 12:57:12 +01:00
parent c898aafbed
commit eb2b18721d
No known key found for this signature in database
GPG Key ID: 92A07DF49CCB0622
1 changed files with 4 additions and 2 deletions

View File

@ -5,8 +5,9 @@ import time
import platform import platform
import subprocess import subprocess
def wait_pid(pid): def wait_pid(pid):
max_attempts = 600 # 600 * 0.1 seconds = 1 minute max_attempts = 600 # 600 * 0.1 seconds = 1 minute
sleep_time = 0.1 sleep_time = 0.1
for i in range(max_attempts): for i in range(max_attempts):
@ -15,7 +16,7 @@ def wait_pid(pid):
# Windows approach: use tasklist to check for the existence of the process. # Windows approach: use tasklist to check for the existence of the process.
try: try:
# Get the output of 'tasklist' # Get the output of 'tasklist'
output = subprocess.check_output(['tasklist'], text=True) output = subprocess.check_output(["tasklist"], text=True)
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
print("[wait_pid] Error retrieving tasklist. Assuming process has ended.") print("[wait_pid] Error retrieving tasklist. Assuming process has ended.")
return 0 return 0
@ -37,6 +38,7 @@ def wait_pid(pid):
print(f"Timeout: Process {pid} did not end within 1 minute") print(f"Timeout: Process {pid} did not end within 1 minute")
return 1 return 1
try: try:
pid = int(sys.argv[1]) pid = int(sys.argv[1])
except ValueError: except ValueError: