当前位置: 首页>>代码示例>>Python>>正文


Python Popen._mpipe_last方法代码示例

本文整理汇总了Python中subprocess.Popen._mpipe_last方法的典型用法代码示例。如果您正苦于以下问题:Python Popen._mpipe_last方法的具体用法?Python Popen._mpipe_last怎么用?Python Popen._mpipe_last使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在subprocess.Popen的用法示例。


在下文中一共展示了Popen._mpipe_last方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: write

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import _mpipe_last [as 别名]
def write(proc : Popen, data):
    """Write message to the process."""
    if proc._mpipe_last == "write":
        raise RuntimeError("Consecutive write not allowed in rpc_mode")
    proc._mpipe_last = "write"
    pack = umsgpack.dumps(data)
    size = bytes(ctypes.c_size_t(len(pack)))
    proc.stdin.write(size)
    proc.stdin.write(pack)
    proc.stdin.flush()
开发者ID:ganwell,项目名称:chirp,代码行数:12,代码来源:mpipe.py

示例2: read

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import _mpipe_last [as 别名]
def read(proc : Popen):
    """Read message from the process, returns None on failure."""
    if proc._mpipe_last == "read":
        raise RuntimeError("Consecutive read not allowed in rpc_mode")
    proc._mpipe_last = "read"
    size = proc.stdout.read(ctypes.sizeof(ctypes.c_size_t))
    size = int.from_bytes(size,  sys.byteorder)
    pack = proc.stdout.read(size)
    try:
        return umsgpack.loads(pack)
    except umsgpack.InsufficientDataException as e:
        if proc.poll() != 0:
            raise RuntimeError(
                "The process returned %d." % proc.returncode
            ) from e
        else:
            raise
开发者ID:ganwell,项目名称:chirp,代码行数:19,代码来源:mpipe.py

示例3: open

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import _mpipe_last [as 别名]
def open(args : list) -> Popen:
    """Open a subprocess for sending message-pack messages."""
    if os.environ.get("MPP_RR") == "True":
        proc = Popen(["rr"] + args, stdin=PIPE, stdout=PIPE)
    elif mc:
        proc = Popen(
            [
                "valgrind",
                "--tool=memcheck",
                "--leak-check=full",
                "--show-leak-kinds=all",
                "--errors-for-leak-kinds=all",
                "--error-exitcode=1",
                "--suppressions=%s" % mc,
            ] + args,
            stdin=PIPE,
            stdout=PIPE,
            preexec_fn=os.setsid
        )
    else:
        proc = Popen(args, stdin=PIPE, stdout=PIPE, preexec_fn=os.setsid)
    proc._mpipe_last = None
    return proc
开发者ID:ganwell,项目名称:chirp,代码行数:25,代码来源:mpipe.py


注:本文中的subprocess.Popen._mpipe_last方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。