本文整理汇总了Python中tornado.process方法的典型用法代码示例。如果您正苦于以下问题:Python tornado.process方法的具体用法?Python tornado.process怎么用?Python tornado.process使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tornado
的用法示例。
在下文中一共展示了tornado.process方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_import_everything
# 需要导入模块: import tornado [as 别名]
# 或者: from tornado import process [as 别名]
def test_import_everything(self):
# Test that all Tornado modules can be imported without side effects,
# specifically without initializing the default asyncio event loop.
# Since we can't tell which modules may have already beein imported
# in our process, do it in a subprocess for a clean slate.
proc = subprocess.Popen([sys.executable], stdin=subprocess.PIPE)
proc.communicate(_import_everything)
self.assertEqual(proc.returncode, 0)
示例2: get_cwd
# 需要导入模块: import tornado [as 别名]
# 或者: from tornado import process [as 别名]
def get_cwd(self):
"""Get the current working directory for our process
Override in subclass to launch the process in a directory
other than the current.
"""
return os.getcwd()
示例3: get_env
# 需要导入模块: import tornado [as 别名]
# 或者: from tornado import process [as 别名]
def get_env(self):
'''Set up extra environment variables for process. Typically
overridden in subclasses.'''
return {}
示例4: get_timeout
# 需要导入模块: import tornado [as 别名]
# 或者: from tornado import process [as 别名]
def get_timeout(self):
"""
Return timeout (in s) to wait before giving up on process readiness
"""
return 5
示例5: ensure_process
# 需要导入模块: import tornado [as 别名]
# 或者: from tornado import process [as 别名]
def ensure_process(self):
"""
Start the process
"""
# We don't want multiple requests trying to start the process at the same time
# FIXME: Make sure this times out properly?
# Invariant here should be: when lock isn't being held, either 'proc' is in state &
# running, or not.
with (await self.state['proc_lock']):
if 'proc' not in self.state:
# FIXME: Prevent races here
# FIXME: Handle graceful exits of spawned processes here
cmd = self.get_cmd()
server_env = os.environ.copy()
# Set up extra environment variables for process
server_env.update(self.get_env())
timeout = self.get_timeout()
proc = SupervisedProcess(self.name, *cmd, env=server_env, ready_func=self._http_ready_func, ready_timeout=timeout, log=self.log)
self.state['proc'] = proc
try:
await proc.start()
is_ready = await proc.ready()
if not is_ready:
await proc.kill()
raise web.HTTPError(500, 'could not start {} in time'.format(self.name))
except:
# Make sure we remove proc from state in any error condition
del self.state['proc']
raise