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


Python NailgunProtocol.iter_chunks方法代码示例

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


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

示例1: test_iter_chunks

# 需要导入模块: from pants.java.nailgun_protocol import NailgunProtocol [as 别名]
# 或者: from pants.java.nailgun_protocol.NailgunProtocol import iter_chunks [as 别名]
  def test_iter_chunks(self):
    expected_chunks = [
      (ChunkType.COMMAND, self.TEST_COMMAND),
      (ChunkType.STDOUT, self.TEST_OUTPUT),
      (ChunkType.STDERR, self.TEST_OUTPUT),
      (ChunkType.EXIT, self.EMPTY_PAYLOAD)
      # N.B. without an EXIT chunk here (or socket failure), this test will deadlock in iter_chunks.
    ]

    for chunk_type, payload in expected_chunks:
      NailgunProtocol.write_chunk(self.server_sock, chunk_type, payload)

    for i, chunk in enumerate(NailgunProtocol.iter_chunks(self.client_sock)):
      self.assertEqual(chunk, expected_chunks[i])
开发者ID:Gointer,项目名称:pants,代码行数:16,代码来源:test_nailgun_protocol.py

示例2: run

# 需要导入模块: from pants.java.nailgun_protocol import NailgunProtocol [as 别名]
# 或者: from pants.java.nailgun_protocol.NailgunProtocol import iter_chunks [as 别名]
  def run(self):
    try:
      for chunk_type, payload in NailgunProtocol.iter_chunks(self._socket, return_bytes=True):
        if self.is_stopped:
          return

        if chunk_type == ChunkType.STDIN:
          self._write_handle.write(payload)
          self._write_handle.flush()
        elif chunk_type == ChunkType.STDIN_EOF:
          return
        else:
          raise NailgunProtocol.ProtocolError(
            'received unexpected chunk {} -> {}'.format(chunk_type, payload)
          )
    finally:
      self._write_handle.close()
开发者ID:baroquebobcat,项目名称:pants,代码行数:19,代码来源:nailgun_io.py

示例3: test_handle_error

# 需要导入模块: from pants.java.nailgun_protocol import NailgunProtocol [as 别名]
# 或者: from pants.java.nailgun_protocol.NailgunProtocol import iter_chunks [as 别名]
 def test_handle_error(self):
   self.handler.handle_error()
   last_chunk_type, last_payload = list(NailgunProtocol.iter_chunks(self.client_sock))[-1]
   self.assertEquals(last_chunk_type, ChunkType.EXIT)
   self.assertEquals(bytes(last_payload), '1')
开发者ID:CaitieM20,项目名称:pants,代码行数:7,代码来源:test_pailgun_server.py


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