本文整理汇总了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])
示例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()
示例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')