Skip to content

Commit 8414d02

Browse files
committed
fix: rewritten __poll() using psutil
1 parent c3312db commit 8414d02

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/DIRAC/Core/Utilities/Subprocess.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ def __init__(self, timeout=False, bufferLimit=52428800):
162162

163163
self.child = None
164164
self.childPID = 0
165-
self.childKilled = False
166165
self.callback = None
167166
self.bufferList = []
168167
self.cmdSeq = []
@@ -252,7 +251,12 @@ def __terminateProcess(self, process):
252251
return psutil.wait_procs([process], timeout=60)
253252

254253
def __poll(self, pid):
255-
"""return pid status"""
254+
"""Non-blocking check of whether process `pid` is still alive.
255+
Returns:
256+
- (0, 0) if process is still running (like os.waitpid(pid, os.WNOHANG))
257+
- (pid, exitcode) if process has terminated
258+
- None if process info cannot be retrieved
259+
"""
256260
try:
257261
p = psutil.Process(pid)
258262
exitcode = p.wait(timeout=0)

0 commit comments

Comments
 (0)