本文整理汇总了Python中tornado.process.Subprocess.wait_for_exit方法的典型用法代码示例。如果您正苦于以下问题:Python Subprocess.wait_for_exit方法的具体用法?Python Subprocess.wait_for_exit怎么用?Python Subprocess.wait_for_exit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tornado.process.Subprocess
的用法示例。
在下文中一共展示了Subprocess.wait_for_exit方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_sigchild_future
# 需要导入模块: from tornado.process import Subprocess [as 别名]
# 或者: from tornado.process.Subprocess import wait_for_exit [as 别名]
def test_sigchild_future(self):
Subprocess.initialize()
self.addCleanup(Subprocess.uninitialize)
subproc = Subprocess([sys.executable, "-c", "pass"])
ret = yield subproc.wait_for_exit()
self.assertEqual(ret, 0)
self.assertEqual(subproc.returncode, ret)
示例2: test_wait_for_exit_raise_disabled
# 需要导入模块: from tornado.process import Subprocess [as 别名]
# 或者: from tornado.process.Subprocess import wait_for_exit [as 别名]
def test_wait_for_exit_raise_disabled(self):
skip_if_twisted()
Subprocess.initialize()
self.addCleanup(Subprocess.uninitialize)
subproc = Subprocess([sys.executable, '-c', 'import sys; sys.exit(1)'])
ret = yield subproc.wait_for_exit(raise_error=False)
self.assertEqual(ret, 1)
示例3: test_wait_for_exit_raise
# 需要导入模块: from tornado.process import Subprocess [as 别名]
# 或者: from tornado.process.Subprocess import wait_for_exit [as 别名]
def test_wait_for_exit_raise(self):
Subprocess.initialize()
self.addCleanup(Subprocess.uninitialize)
subproc = Subprocess([sys.executable, "-c", "import sys; sys.exit(1)"])
with self.assertRaises(subprocess.CalledProcessError) as cm:
yield subproc.wait_for_exit()
self.assertEqual(cm.exception.returncode, 1)
示例4: send_to_ruby
# 需要导入模块: from tornado.process import Subprocess [as 别名]
# 或者: from tornado.process.Subprocess import wait_for_exit [as 别名]
async def send_to_ruby(self, request_json):
env = {
"PCSD_DEBUG": "true" if self.__debug else "false"
}
if self.__gem_home is not None:
env["GEM_HOME"] = self.__gem_home
if self.__no_proxy is not None:
env["NO_PROXY"] = self.__no_proxy
if self.__https_proxy is not None:
env["HTTPS_PROXY"] = self.__https_proxy
pcsd_ruby = Subprocess(
[
self.__ruby_executable, "-I",
self.__pcsd_dir,
self.__pcsd_cmdline_entry
],
stdin=Subprocess.STREAM,
stdout=Subprocess.STREAM,
stderr=Subprocess.STREAM,
env=env
)
await Task(pcsd_ruby.stdin.write, str.encode(request_json))
pcsd_ruby.stdin.close()
return await multi([
Task(pcsd_ruby.stdout.read_until_close),
Task(pcsd_ruby.stderr.read_until_close),
pcsd_ruby.wait_for_exit(raise_error=False),
])
示例5: test_h2spec
# 需要导入模块: from tornado.process import Subprocess [as 别名]
# 或者: from tornado.process.Subprocess import wait_for_exit [as 别名]
def test_h2spec(self):
h2spec_cmd = [self.h2spec_path, "-p",
str(self.get_http_port())]
for section in options.h2spec_section:
h2spec_cmd.extend(["-s", section])
h2spec_proc = Subprocess(h2spec_cmd)
yield h2spec_proc.wait_for_exit()
示例6: test_sigchild_future
# 需要导入模块: from tornado.process import Subprocess [as 别名]
# 或者: from tornado.process.Subprocess import wait_for_exit [as 别名]
def test_sigchild_future(self):
skip_if_twisted()
Subprocess.initialize()
self.addCleanup(Subprocess.uninitialize)
subproc = Subprocess([sys.executable, '-c', 'pass'])
ret = yield subproc.wait_for_exit()
self.assertEqual(ret, 0)
self.assertEqual(subproc.returncode, ret)
示例7: work1
# 需要导入模块: from tornado.process import Subprocess [as 别名]
# 或者: from tornado.process.Subprocess import wait_for_exit [as 别名]
def work1():
p = Subprocess(['sleep', '5'])
future = p.wait_for_exit()
ioloop.IOLoop.instance().add_future(future, finish_callback)
print('work1: After add_future....')
ioloop.IOLoop.instance().add_callback(dumy_callback)
print ('work1: After add_callback...')
示例8: _recognize_sample_with_gracenote
# 需要导入模块: from tornado.process import Subprocess [as 别名]
# 或者: from tornado.process.Subprocess import wait_for_exit [as 别名]
def _recognize_sample_with_gracenote(self, sample_path):
conf = self.settings['gn_config']
proc = Subprocess([
'tools/gracetune_identify.py',
'--client-id', conf['client_id'],
'--user-id', conf['user_id'],
'--license', conf['license'],
'--filename', sample_path
], stdout=Subprocess.STREAM)
yield proc.wait_for_exit()
ret = yield proc.stdout.read_until_close()
raise Return(json.loads(ret))
示例9: run_command
# 需要导入模块: from tornado.process import Subprocess [as 别名]
# 或者: from tornado.process.Subprocess import wait_for_exit [as 别名]
def run_command(cmd, input=None, env=None):
proc = Subprocess(cmd, shell=True, env=env, stdin=Subprocess.STREAM, stdout=Subprocess.STREAM)
inbytes = None
if input:
inbytes = input.encode()
yield proc.stdin.write(inbytes)
proc.stdin.close()
out = yield proc.stdout.read_until_close()
proc.stdout.close()
err = yield proc.wait_for_exit()
if err != 0:
return err # exit error?
else:
out = out.decode().strip()
return out
示例10: run_command
# 需要导入模块: from tornado.process import Subprocess [as 别名]
# 或者: from tornado.process.Subprocess import wait_for_exit [as 别名]
def run_command(cmd, input=None, env=None):
proc = Subprocess(cmd, shell=True, env=env, stdin=Subprocess.STREAM, stdout=Subprocess.STREAM)
inbytes = None
if input:
inbytes = input.encode()
try:
yield proc.stdin.write(inbytes)
except StreamClosedError as exp:
# Apparently harmless
pass
proc.stdin.close()
out = yield proc.stdout.read_until_close()
proc.stdout.close()
err = yield proc.wait_for_exit()
if err != 0:
return err # exit error?
else:
out = out.decode().strip()
return out
示例11: test_wait_for_exit_raise_disabled
# 需要导入模块: from tornado.process import Subprocess [as 别名]
# 或者: from tornado.process.Subprocess import wait_for_exit [as 别名]
def test_wait_for_exit_raise_disabled(self):
Subprocess.initialize()
self.addCleanup(Subprocess.uninitialize)
subproc = Subprocess([sys.executable, "-c", "import sys; sys.exit(1)"])
ret = yield subproc.wait_for_exit(raise_error=False)
self.assertEqual(ret, 1)
示例12: work2
# 需要导入模块: from tornado.process import Subprocess [as 别名]
# 或者: from tornado.process.Subprocess import wait_for_exit [as 别名]
def work2():
p = Subprocess(['sleep', '2'])
print('work2: Before yield')
ret = yield p.wait_for_exit()
print('work2: After yield, result:', ret)