MCPcopy Create free account
hub / github.com/InternLM/InternBootcamp / start_multiple_workers

Function start_multiple_workers

internbootcamp/utils/tool_server/cli.py:210–233  ·  view source on GitHub ↗

启动多个Worker进程

(tools_config, host, start_port, master_url, num_workers, log_file=None)

Source from the content-addressed store, hash-verified

208
209
210def start_multiple_workers(tools_config, host, start_port, master_url, num_workers, log_file=None):
211 """启动多个Worker进程"""
212 worker_processes = []
213 worker_urls = []
214 current_port = start_port
215
216 print(f"--- 启动 {num_workers} 个Worker进程 ---")
217
218 for i in range(num_workers):
219 worker_port = current_port
220 # Generate a random short id for the worker
221 worker_id = f"{uuid.uuid4().hex[:8]}"
222 worker_url = f"http://{get_external_ip()}:{worker_port}"
223 worker_urls.append(worker_url)
224
225 process = multiprocessing.Process(
226 target=start_worker_process,
227 args=(tools_config, host, worker_port, worker_id, master_url, log_file)
228 )
229 process.start()
230 worker_processes.append(process)
231 current_port = worker_port + 1
232
233 return worker_processes, worker_urls
234
235
236def test_servers(server_url, tool_names, test_timeout=10, connectivity_only=False):

Callers 1

mainFunction · 0.85

Calls 3

get_external_ipFunction · 0.85
appendMethod · 0.80
startMethod · 0.45

Tested by

no test coverage detected