mirror of
https://github.com/agentscope-ai/ReMe.git
synced 2026-08-28 05:25:04 +00:00
feat(context): reinitialize thread pool and Ray when starting service context
This commit is contained in:
parent
52d21392f2
commit
99b26c1fdc
1 changed files with 13 additions and 0 deletions
|
|
@ -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.")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue