Skip to content

Commit 8118636

Browse files
committed
Revert "fix: register shutting down process pool for early execution"
This reverts commit 4c716e5.
1 parent 4c716e5 commit 8118636

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

python/cocoindex/subprocess_exec.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import asyncio
2020
import os
2121
import time
22+
import atexit
2223
from .user_app_loader import load_user_app
2324
from .runtime import execution_context
2425
import logging
@@ -62,18 +63,10 @@ def _get_pool() -> ProcessPoolExecutor:
6263
with _pool_lock:
6364
if _pool is None:
6465
if not _pool_cleanup_registered:
65-
# CRITICAL: register with threading's early-exit list
66-
reg = getattr(threading, "_register_atexit", None)
67-
if callable(reg):
68-
reg(_shutdown_pool_at_exit) # goes ahead of normal atexit
69-
_pool_cleanup_registered = True
70-
else:
71-
# Fallback for odd Pythons: normal atexit (will run later)
72-
import atexit
73-
74-
if not _pool_cleanup_registered:
75-
atexit.register(_shutdown_pool_at_exit)
76-
_pool_cleanup_registered = True
66+
# Register the shutdown at exit at creation time (rather than at import time)
67+
# to make sure it's executed earlier in the shutdown sequence.
68+
atexit.register(_shutdown_pool_at_exit)
69+
_pool_cleanup_registered = True
7770

7871
# Single worker process as requested
7972
_pool = ProcessPoolExecutor(

0 commit comments

Comments
 (0)