clusterservice.py 文件源码

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

项目:maas 作者: maas 项目源码 文件源码
def spawnProcessAndNullifyStdout(protocol, args):
    """"Utility function to spawn a process and redirect stdout to /dev/null.

    Spawns the process with the specified `protocol` in the reactor, with the
    specified list of binary `args`.
    """
    # Using childFDs we arrange for the child's stdout to go to /dev/null
    # and for stderr to be read asynchronously by the reactor.
    with open(os.devnull, "r+b") as devnull:
        # This file descriptor to /dev/null will be closed before the
        # spawned process finishes, but will remain open in the spawned
        # process; that's the Magic Of UNIX™.
        reactor.spawnProcess(
            protocol, args[0], args, childFDs={
                0: devnull.fileno(),
                1: devnull.fileno(),
                2: 'r'
            },
            env=select_c_utf8_bytes_locale())
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号