增加环绕侦察场景适配
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
from __future__ import annotations
|
||||
|
||||
__all__ = (
|
||||
"run_sync",
|
||||
"current_default_interpreter_limiter",
|
||||
)
|
||||
|
||||
import atexit
|
||||
import os
|
||||
import sys
|
||||
@@ -20,7 +25,9 @@ else:
|
||||
if sys.version_info >= (3, 14):
|
||||
from concurrent.interpreters import ExecutionFailed, create
|
||||
|
||||
def _interp_call(func: Callable[..., Any], args: tuple[Any, ...]):
|
||||
def _interp_call(
|
||||
func: Callable[..., Any], args: tuple[Any, ...]
|
||||
) -> tuple[Any, bool]:
|
||||
try:
|
||||
retval = func(*args)
|
||||
except BaseException as exc:
|
||||
@@ -28,7 +35,7 @@ if sys.version_info >= (3, 14):
|
||||
else:
|
||||
return retval, False
|
||||
|
||||
class Worker:
|
||||
class _Worker:
|
||||
last_used: float = 0
|
||||
|
||||
def __init__(self) -> None:
|
||||
@@ -90,7 +97,7 @@ except NotShareableError:
|
||||
"exec",
|
||||
)
|
||||
|
||||
class Worker:
|
||||
class _Worker:
|
||||
last_used: float = 0
|
||||
|
||||
def __init__(self) -> None:
|
||||
@@ -128,7 +135,7 @@ except NotShareableError:
|
||||
return res
|
||||
else:
|
||||
|
||||
class Worker:
|
||||
class _Worker:
|
||||
last_used: float = 0
|
||||
|
||||
def __init__(self) -> None:
|
||||
@@ -153,11 +160,11 @@ MAX_WORKER_IDLE_TIME = (
|
||||
T_Retval = TypeVar("T_Retval")
|
||||
PosArgsT = TypeVarTuple("PosArgsT")
|
||||
|
||||
_idle_workers = RunVar[deque[Worker]]("_available_workers")
|
||||
_idle_workers = RunVar[deque[_Worker]]("_available_workers")
|
||||
_default_interpreter_limiter = RunVar[CapacityLimiter]("_default_interpreter_limiter")
|
||||
|
||||
|
||||
def _stop_workers(workers: deque[Worker]) -> None:
|
||||
def _stop_workers(workers: deque[_Worker]) -> None:
|
||||
for worker in workers:
|
||||
worker.destroy()
|
||||
|
||||
@@ -199,7 +206,7 @@ async def run_sync(
|
||||
try:
|
||||
worker = idle_workers.pop()
|
||||
except IndexError:
|
||||
worker = Worker()
|
||||
worker = _Worker()
|
||||
|
||||
try:
|
||||
return await to_thread.run_sync(
|
||||
|
||||
Reference in New Issue
Block a user