本文整理汇总了Python中pants.java.nailgun_protocol.NailgunProtocol.send_exit_with_code方法的典型用法代码示例。如果您正苦于以下问题:Python NailgunProtocol.send_exit_with_code方法的具体用法?Python NailgunProtocol.send_exit_with_code怎么用?Python NailgunProtocol.send_exit_with_code使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pants.java.nailgun_protocol.NailgunProtocol
的用法示例。
在下文中一共展示了NailgunProtocol.send_exit_with_code方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: exit
# 需要导入模块: from pants.java.nailgun_protocol import NailgunProtocol [as 别名]
# 或者: from pants.java.nailgun_protocol.NailgunProtocol import send_exit_with_code [as 别名]
def exit(self, result=0, msg=None, *args, **kwargs):
"""Exit the runtime."""
if self._finalizer:
try:
self._finalizer()
except Exception as e:
try:
NailgunProtocol.send_stderr(
self._socket,
'\nUnexpected exception in finalizer: {!r}\n'.format(e)
)
except Exception:
pass
try:
# Write a final message to stderr if present.
if msg:
NailgunProtocol.send_stderr(self._socket, msg)
# Send an Exit chunk with the result.
NailgunProtocol.send_exit_with_code(self._socket, result)
# Shutdown the connected socket.
teardown_socket(self._socket)
finally:
super(DaemonExiter, self).exit(result=result, *args, **kwargs)
示例2: test_send_exit_with_code
# 需要导入模块: from pants.java.nailgun_protocol import NailgunProtocol [as 别名]
# 或者: from pants.java.nailgun_protocol.NailgunProtocol import send_exit_with_code [as 别名]
def test_send_exit_with_code(self):
return_code = 1
NailgunProtocol.send_exit_with_code(self.server_sock, return_code)
chunk_type, payload = NailgunProtocol.read_chunk(self.client_sock, return_bytes=True)
self.assertEqual(
(chunk_type, payload),
(ChunkType.EXIT, NailgunProtocol.encode_int(return_code))
)
示例3: handle_error
# 需要导入模块: from pants.java.nailgun_protocol import NailgunProtocol [as 别名]
# 或者: from pants.java.nailgun_protocol.NailgunProtocol import send_exit_with_code [as 别名]
def handle_error(self, exc=None):
"""Error handler for failed calls to handle()."""
if exc:
NailgunProtocol.send_stderr(self.request, traceback.format_exc())
failure_code = 1
NailgunProtocol.send_exit_with_code(self.request, failure_code)