asyncfile.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:pycos 作者: pgiri 项目源码 文件源码
def __init__(self, first, last=None):
        """'first' is a Popen object. 'last', if given, is another
        Popen object that is the end of the joints to 'first'.

        'write' operations send data to first's stdin and 'read'
        operations get data from last's stdout/stderr.
        """
        if not last:
            last = first
        self.first = first
        self.last = last
        if platform.system() == 'Windows':
            if not isinstance(first, Popen) or not isinstance(last, Popen):
                raise ValueError('argument must be asyncfile.Popen object')
            if first.stdin:
                self.stdin = first.stdin
            else:
                self.stdin = None
            if last.stdout:
                self.stdout = last.stdout
            else:
                self.stdout = None
            if last.stderr:
                self.stderr = last.stderr
            else:
                self.stderr = None
        else:
            if not isinstance(first, subprocess.Popen) or not isinstance(last, subprocess.Popen):
                raise ValueError('argument must be subprocess.Popen object')
            if first.stdin:
                self.stdin = AsyncFile(first.stdin)
            else:
                self.stdin = None
            if last.stdout:
                self.stdout = AsyncFile(last.stdout)
            else:
                self.stdout = None
            if last.stderr:
                self.stderr = AsyncFile(last.stderr)
            else:
                self.stderr = None
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号