本文整理汇总了Python中psutil.CONN_CLOSE_WAIT属性的典型用法代码示例。如果您正苦于以下问题:Python psutil.CONN_CLOSE_WAIT属性的具体用法?Python psutil.CONN_CLOSE_WAIT怎么用?Python psutil.CONN_CLOSE_WAIT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类psutil
的用法示例。
在下文中一共展示了psutil.CONN_CLOSE_WAIT属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_tcp
# 需要导入模块: import psutil [as 别名]
# 或者: from psutil import CONN_CLOSE_WAIT [as 别名]
def test_tcp(self):
addr = ("127.0.0.1", get_free_port())
assert not thisproc.connections(kind='tcp4')
server, client = tcp_socketpair(AF_INET, addr=addr)
try:
cons = thisproc.connections(kind='tcp4')
self.assertEqual(len(cons), 2)
self.assertEqual(cons[0].status, psutil.CONN_ESTABLISHED)
self.assertEqual(cons[1].status, psutil.CONN_ESTABLISHED)
# May not be fast enough to change state so it stays
# commenteed.
# client.close()
# cons = thisproc.connections(kind='all')
# self.assertEqual(len(cons), 1)
# self.assertEqual(cons[0].status, psutil.CONN_CLOSE_WAIT)
finally:
server.close()
client.close()
示例2: assert_free_resources
# 需要导入模块: import psutil [as 别名]
# 或者: from psutil import CONN_CLOSE_WAIT [as 别名]
def assert_free_resources():
ts = threading.enumerate()
assert len(ts) == 1, ts
p = psutil.Process()
children = p.children()
if children:
for p in children:
p.kill()
p.wait(1)
assert not children, children
cons = [x for x in p.connections('tcp')
if x.status != psutil.CONN_CLOSE_WAIT]
assert not cons, cons