"""Thread execution pool."""from__future__importannotationsfromconcurrent.futuresimportFuture,ThreadPoolExecutor,waitfromtypingimportTYPE_CHECKING,Any,Callablefrom.baseimportBasePool,apply_target__all__=('TaskPool',)ifTYPE_CHECKING:fromtypingimportTypedDictPoolInfo=TypedDict('PoolInfo',{'max-concurrency':int,'threads':int})# `TargetFunction` should be a Protocol that represents fast_trace_task and# trace_task_ret.TargetFunction=Callable[...,Any]classApplyResult:def__init__(self,future:Future)->None:self.f=futureself.get=self.f.resultdefwait(self,timeout:float|None=None)->None:wait([self.f],timeout)