feat(context): reinitialize thread pool and Ray when starting service context

This commit is contained in:
jinli.yl 2026-02-12 21:02:05 +08:00
parent 52d21392f2
commit 99b26c1fdc

View file

@ -169,6 +169,19 @@ class ServiceContext(BaseContext):
async def start(self):
"""Start the service context by initializing all configured components."""
# Recreate thread pool if it was shut down
if self.thread_pool is None or self.thread_pool._shutdown:
self.thread_pool = ThreadPoolExecutor(
max_workers=self.service_config.thread_pool_max_workers,
)
# Re-initialize Ray if it was shut down
if self.service_config.ray_max_workers > 1:
import ray
if not ray.is_initialized():
ray.init(num_cpus=self.service_config.ray_max_workers)
for name, config in self.service_config.llms.items():
if config.backend not in R.llms:
logger.warning(f"LLM backend {config.backend} is not supported.")