def start(self, command=None, **options):
"""Start the specified ``command`` with the requested **options"""
if self.running:
raise OSError("Process {:d} is still running.".format(self.id))
if self.updater or len(self.threads):
raise OSError("Process {:d} management threads are still running.".format(self.id))
kwds = dict(self.__kwds)
kwds.update(options)
command = command or self.commandline
env = kwds.get('env', os.environ)
cwd = kwds.get('cwd', os.getcwd())
newlines = kwds.get('newlines', True)
shell = kwds.get('shell', False)
stdout,stderr = options.pop('stdout',self.stdout),options.pop('stderr',self.stderr)
self.program = process.subprocess(command, cwd, env, newlines, joined=(stderr is None) or stdout == stderr, shell=shell, show=kwds.get('show', False))
self.commandline = command
self.eventWorking.clear()
# monitor program's i/o
self.__start_monitoring(stdout, stderr)
self.__start_updater(timeout=kwds.get('timeout',-1))
# start monitoring
self.eventWorking.set()
return self
评论列表
文章目录