本文整理汇总了Python中multiprocessing.Process.cmd方法的典型用法代码示例。如果您正苦于以下问题:Python Process.cmd方法的具体用法?Python Process.cmd怎么用?Python Process.cmd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类multiprocessing.Process
的用法示例。
在下文中一共展示了Process.cmd方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: master
# 需要导入模块: from multiprocessing import Process [as 别名]
# 或者: from multiprocessing.Process import cmd [as 别名]
def master(queue, rep_queue, outputs):
from multiprocessing import Process
import logging
from settings import add_fab_to_env_path
logging.basicConfig(
level=logging.DEBUG,
format='%(asctime)s %(levelname)s - %(message)s',
datefmt='%d/%m/%Y %H:%M:%S',
filename="master.log"
)
logging.info("<master up!>")
add_fab_to_env_path()
workers = []
while True:
try:
(cmd,) = queue.get()
except:
break
logging.debug("master rcv cmd : %s" % cmd)
workers = [w for w in workers if w.is_alive()] # gc ?
if cmd == "l":
rep = [(w.pid, w.cmd) for w in workers]
else:
w = Process(target=run_command, args=[cmd, outputs])
w.cmd = cmd
w.start()
workers.append(w)
rep = w.pid
rep_queue.put(rep)
logging.info("<master down!>")