Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions .github/workflows/_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,6 @@ jobs:
run: |
${{ matrix.platform.python_exec }} -m mypy python
- name: Python tests
if: ${{ !startsWith(matrix.platform.runner, 'windows') }}
run: |
${{ matrix.platform.python_exec }} -m pytest --capture=no python/cocoindex/tests
- name: Python tests (Windows cmd)
if: ${{ startsWith(matrix.platform.runner, 'windows') }}
shell: cmd # Use `cmd` to run test for Windows, as PowerShell doesn't detect exit code by `os._exit(0)` correctly.
run: |
${{ matrix.platform.python_exec }} -m pytest --capture=no python/cocoindex/tests
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ dependencies = [
"python-dotenv>=1.1.0",
"watchfiles>=1.1.0",
"numpy>=1.23.2",
"psutil>=7.0.0",
]
license = "Apache-2.0"
license-files = ["THIRD_PARTY_NOTICES.html"]
Expand Down
25 changes: 17 additions & 8 deletions python/cocoindex/subprocess_exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,18 +134,27 @@ def _start_parent_watchdog(
This runs in a background daemon thread so it never blocks pool work.
"""

import psutil # type: ignore

if parent_pid is None:
parent_pid = os.getppid()

try:
p = psutil.Process(parent_pid)
# Cache create_time to defeat PID reuse.
created = p.create_time()
except psutil.Error:
# Parent already gone or not accessible
os._exit(1)

def _watch() -> None:
while True:
# If PPID changed (parent died and we were reparented), exit.
if os.getppid() != parent_pid:
os._exit(1)

# Best-effort liveness probe in case PPID was reused.
try:
os.kill(parent_pid, 0)
except OSError:
# is_running() + same create_time => same process and still alive
if not (p.is_running() and p.create_time() == created):
os._exit(1)
except psutil.NoSuchProcess:
os._exit(1)

time.sleep(interval_seconds)

threading.Thread(target=_watch, name="parent-watchdog", daemon=True).start()
Expand Down
38 changes: 0 additions & 38 deletions python/cocoindex/tests/conftest.py

This file was deleted.

Loading