mirror of
https://github.com/hanzoai/python-sdk.git
synced 2026-10-23 20:23:00 +00:00
fix: handle asyncio.subprocess.Process in list_processes
ProcessManager.list_processes() was calling .poll() which only exists on subprocess.Popen, not asyncio.subprocess.Process. Since auto_background.py uses asyncio.create_subprocess_exec(), the stored process objects don't have poll(). Now checks for .returncode directly for asyncio processes.
This commit is contained in:
@@ -47,7 +47,15 @@ class ProcessManager:
|
||||
"""List all tracked processes."""
|
||||
result = {}
|
||||
for pid, proc in list(self._processes.items()):
|
||||
if proc.poll() is None:
|
||||
# Handle both subprocess.Popen and asyncio.subprocess.Process
|
||||
# subprocess.Popen has .poll(), asyncio.subprocess.Process uses .returncode
|
||||
try:
|
||||
is_running = proc.poll() is None if hasattr(proc, 'poll') else proc.returncode is None
|
||||
except Exception:
|
||||
# If we can't determine, assume running
|
||||
is_running = True
|
||||
|
||||
if is_running:
|
||||
result[pid] = {
|
||||
"pid": proc.pid,
|
||||
"running": True,
|
||||
|
||||
Reference in New Issue
Block a user