recipe-574437.py 文件源码

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

项目:code 作者: ActiveState 项目源码 文件源码
def input(s, stdout = True, timeout = 2,
            prompt = rgx2nd(('(.+)', 'py3to2 server: \\1'), ),
            subprompt = rgx2nd(('>>> ', '', None), ),
            fndexc = re.compile('\WTraceback '),
            ):
    self = _server
    if not s: return
    SERVER.stdin.write(s)
    try:
      buf = ''
      SERVER.stdin.write("\n\nimport os, signal; os.kill(CLIENTPID, signal.SIGINT)\n")
      time.sleep(timeout)
      raise IOError('py3to2 server not responding to input: %s'%repr(s))
    except KeyboardInterrupt:
      buf = os.read(SERVERIO[0], self.bufsize)
      buf = subprompt.sub(buf)
      if prompt: buf = prompt.sub(buf)
    if fndexc.search(buf): raise IOError('py3to2 server input: %s\n%s'%(s, buf))
    if stdout: sys.stdout.write(buf)
    else: return buf
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号