本文整理汇总了Python中subprocess.Popen.prefix方法的典型用法代码示例。如果您正苦于以下问题:Python Popen.prefix方法的具体用法?Python Popen.prefix怎么用?Python Popen.prefix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类subprocess.Popen
的用法示例。
在下文中一共展示了Popen.prefix方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Thread
# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import prefix [as 别名]
printer_thread = Thread(target=printer)
printer_thread.start()
configs = []
for i in range(1, N_CONFIG + 1):
path = BASE_DATA_PATH + "config_" + str(i)
os.makedirs(path)
config = Popen(
[mongod, "--port", str(20000 + i), "--configsvr", "--dbpath", path] + CONFIG_ARGS,
stdin=devnull,
stdout=PIPE,
stderr=STDOUT,
)
config.prefix = ascolor(CONFIG_COLOR, "C" + str(i)) + ":"
fds[config.stdout] = config
procs.append(config)
waitfor(config, 20000 + i)
configs.append("localhost:" + str(20000 + i))
for i in range(1, N_SHARDS + 1):
path = BASE_DATA_PATH + "shard_" + str(i)
os.makedirs(path)
shard = Popen(
[mongod, "--port", str(30000 + i), "--shardsvr", "--dbpath", path] + MONGOD_ARGS,
stdin=devnull,
stdout=PIPE,
stderr=STDOUT,
)
示例2: range
# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import prefix [as 别名]
nodes = []
for i in range(options.set_size):
path = os.path.join(options.dbpath, "rs_" + str(i))
os.makedirs(path)
port = str(options.port + i)
seed = options.name + "/" + ",".join(nodes)
command = [mongod, "--port", port, "--dbpath", path, "--replSet", seed, "--rest"]
if i < options.arbiters:
command += ["--oplogSize", "1"]
prefix = "A" + str(i)
else:
command += ["--oplogSize", str(options.oplog_size)]
prefix = "R" + str(i - options.arbiters)
node = Popen(command, stdout=PIPE, stderr=STDOUT)
node.prefix = ascolor(get_color(i), prefix) + ":"
fds[node.stdout] = node
procs.append(node)
waitfor(node, options.port + i)
nodes.append("localhost:%s" % port)
config = {"_id": options.name,
"members": []}
for i in range(len(nodes)):
member = {"_id": i, "host": nodes[i]}
if i < options.arbiters:
member["arbiterOnly"] = True
config["members"].append(member)
sleep(10)
示例3: Thread
# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import prefix [as 别名]
del fds[file]
break
break
printer_thread = Thread(target=printer)
printer_thread.start()
configs = []
for i in range(1, N_CONFIG+1):
path = BASE_DATA_PATH +'config_' + str(i)
os.makedirs(path)
#print mongod,' --port ',str(20000+i),' --configsvr',' --dbpath ',path
config = Popen([mongod, '--port', str(20000 + i), '--configsvr', '--dbpath', path] + CONFIG_ARGS,
stdin=devnull, stdout=PIPE, stderr=STDOUT)
config.prefix = ascolor(CONFIG_COLOR, 'C' + str(i)) + ':'
fds[config.stdout] = config
procs.append(config)
waitfor(config, 20000 + i)
configs.append('localhost:' + str(20000 + i))
for i in range(1, N_SHARDS+1):
path = BASE_DATA_PATH +'shard_' + str(i)
os.makedirs(path)
shard = Popen([mongod, '--port', str(30000 + i), '--shardsvr', '--dbpath', path] + MONGOD_ARGS,
stdin=devnull, stdout=PIPE, stderr=STDOUT)
shard.prefix = ascolor(MONGOD_COLOR, 'M' + str(i)) + ':'
fds[shard.stdout] = shard
procs.append(shard)
waitfor(shard, 30000 + i)