def run(self):
"""Set up input/output streams and execute the child function in a new
thread. This is part of the `threading.Thread` interface and should
not be called directly.
"""
if self.f is None:
return
if self.stdin is not None:
sp_stdin = io.TextIOWrapper(self.stdin)
else:
sp_stdin = io.StringIO("")
if ON_WINDOWS:
if self.c2pwrite != -1:
self.c2pwrite = msvcrt.open_osfhandle(self.c2pwrite.Detach(), 0)
if self.errwrite != -1:
self.errwrite = msvcrt.open_osfhandle(self.errwrite.Detach(), 0)
if self.c2pwrite != -1:
sp_stdout = io.TextIOWrapper(io.open(self.c2pwrite, 'wb', -1))
else:
sp_stdout = sys.stdout
if self.errwrite == self.c2pwrite:
sp_stderr = sp_stdout
elif self.errwrite != -1:
sp_stderr = io.TextIOWrapper(io.open(self.errwrite, 'wb', -1))
else:
sp_stderr = sys.stderr
r = self.f(self.args, sp_stdin, sp_stdout, sp_stderr)
self.returncode = 0 if r is None else r
评论列表
文章目录