Shortcuts

框架.并行

并行

并行

class ding.framework.parallel.Parallel(*args, **kwargs)[source]
classmethod runner(n_parallel_workers: int, mq_type: str = 'nng', attach_to: List[str] | None = None, protocol: str = 'ipc', address: str | None = None, ports: List[int] | int | None = None, topology: str = 'mesh', labels: Set[str] | None = None, node_ids: List[int] | int | None = None, auto_recover: bool = False, max_retries: int = inf, redis_host: str | None = None, redis_port: int | None = None, startup_interval: int = 1) Callable[源代码]
Overview:

此方法允许您配置并行参数,您现在仍在父进程中。

Arguments:
  • n_parallel_workers (int): 要生成的工人数量。

  • mq_type (str): 嵌入式消息队列类型,例如 nng, redis。

  • attach_to (Optional[List[str]]): 你想要附加到的节点的地址。

  • 协议 (str): 网络协议。

  • 地址 (Optional[str]): 绑定地址,IP 或文件路径。

  • 端口 (Optional[List[int]]): 候选端口。

  • topology (str): Network topology, includes:

    mesh(默认):彼此之间完全连接; star:仅连接到第一个节点; alone:不连接到任何节点,除了附加到的节点;

  • 标签 (Optional[Set[str]]): 标签。

  • node_ids (Optional[List[int]]): 候选节点ID。

  • auto_recover (bool): 自动从主函数中未捕获的异常中恢复。

  • max_retries (int): 自动恢复的最大重试次数。

  • redis_host (str): Redis服务器主机。

  • redis_port (int): Redis服务器端口。

  • startup_interval (int): 每个任务之间的启动间隔。

Returns:
  • _runner (Callable): 主函数的包装函数。