一种实用程序,它将任务分布在固定数量的进程上,并整理输出,以更好地利用多进程

disttask的Python项目详细描述


disttask是一个实用程序,它提供了跨固定数量的进程分发任务并整理输出的能力,以更好地利用多处理。

使用现有的单线程/进程工具和脚本,充分利用计算机资源。

提供跨固定数量的进程分发任务的能力,以更好地利用多处理。

用法

Usage: disttask [cmd] [concurrent tasks] [argset]

Use a %s in [cmd] where you want the args to go. use %d for the pipe number.

To run a list of commands (job server), have ‘%s’ be your full command.

If you need a literal %s or %d, use %%s or %%d.

Options:

-nc or –no-collate By default, the output will be held until the task is completed, so output is not intermixed.

By providing “-nc” or “–no-collate”, instead each line that comes in from any running task

is printed, prefixed with the argset in square-brackets (e.x. “[arg1] Some message”

来自stdin的参数集

If argset is ‘–’, then the argset items will be read from stdin instead of being provided on the commandline.

Execution begins immediately, so you can use disttask as a job manager with another process feeding in items

as they become available.

最大并发性

You may use “0” or “MAX” as the “concurrent tasks” parameter to execute all items in the argset simultaneously

示例用法

disttask “ssh root@%s hostname” 3 host1 host2 host3 host4 host5 host6 # Connect and get hostname on 6 hosts, 3 at a time.

disttask 2.2.0版

并发性

应用程序最多运行“并发任务”个进程(很好地匹配这个数字-1可用的处理器总数)。 它捕获stdout和stderr,以确保应用程序之间的任何输出都不会交织在一起。

输出

在完成每个任务后,将完整地写入输出,除非提供“-nc”或“–no collate”参数,在这种情况下,只要输出可用,就会立即打印输出,每行的前缀都是方括号中的项名称。

指定命令

每个命令都应该指定一个“%s”到每个参数的位置(每个应用程序@argset中有一个参数)。若要馈送整个命令,只需使用“%s”作为“cmd”,并在“argset”中提供命令。 这些命令由shell执行,因此可以包含shell表达式。

%d也可用作管道编号,可用于区分正在运行的进程。

还可以通过提供“-”作为参数集,将程序或文件管道输出到disttask。disttask将运行并从stdin读取,将每一行视为argset项,并在stdin关闭且所有子进程完成时终止。

示例

使用disttask并行连接到各个主机并执行命令:

disttask “echo -n ‘pipe %d: ‘ && ssh root@%s hostname” 2 “host1” “host2” “host3” “host4”

pipe 0: host1

pipe 1: host2

pipe 0: host3

pipe 1: host4

同样的例子,使用“no collate”选项:

disttask “echo -n ‘pipe %d: ‘ && ssh root@%s hostname” 2 “host1” “host2” “host3” “host4”

[host1] pipe 0: host1

[host2] pipe 1: host2

[host3] pipe 0: host3

[host4] pipe 1: host4

在子目录中的所有python文件上运行pyflakes,同时使用10个进程(需要shopt-s globstar)。注意倒勾,而不是单引号。)

disttask “pyflakes %s” 10 echo **/*.py

用法:disttask[cmd][concurrent tasks][argset]

在[cmd]中使用一个%s作为参数。使用%d作为管道编号。 若要运行命令列表(作业服务器),请将%s作为完整命令。

Options:

-nc or –no-collate By default, the output will be held until the task is completed, so output is not intermixed.
By providing “-nc” or “–no-collate”, instead each line that comes in from any running task is printed, prefixed with the argset in square-brackets (e.x. “[arg1] Some message”

来自stdin的参数集

If argset is ‘–’, then the argset items will be read from stdin instead of being provided on the commandline. Execution begins immediately, so you can use disttask as a job manager with another process feeding in items as they become available.

最大并发性

You may use “0” or “MAX” as the “concurrent tasks” parameter to execute all items in the argset simultaneously

示例用法

disttask “ssh root@%s hostname” 3 host1 host2 host3 host4 host5 host6 # Connect and get hostname on 6 hosts, 3 at a time.

disttask 2.1.1版

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
安卓设置列表视图元素的文本导致应用程序崩溃,MeasureHeaghtToChildren上出现java nullpointer异常   MongoDB java驱动程序行为异常   Java Apache POI整数验证   java如何在没有instanceOf的情况下实现LayoutManager?   JavaJMX:访问运行JVM的文件系统的标准功能   java如何在spring boot中从原始查询中获取数据?   java按钮有不同的大小,即使我给了它们相同的大小?   java访问jasypt的FixedStringSaltGenerator和SetAltGenerator生成的SALT?   java从可用的可能选项中选择QRCODE   java 安卓服务器如何知道客户端断开或关闭   java为什么我的函数即使有一个条件出错也返回true?   java如何将普通文件和文件夹包含到Eclipse产品/插件中?   广播接收器中的java启动活动导致应用程序崩溃   java将列表<String>作为参数传递   表单Java Swing BoxLayout   java我试图将eclipse与oracle 11_g连接起来,但它要求使用ojdbc14。罐子   Kafka Java使用者不使用来自特定分区的消息   java数据源CFG。属性文件被放置在资源文件夹中,但我仍然在eclipse中得到文件未找到异常   java我写得好吗。平等!。equals if语句