本文整理汇总了Python中mininet.node.Node.fdToNode方法的典型用法代码示例。如果您正苦于以下问题:Python Node.fdToNode方法的具体用法?Python Node.fdToNode怎么用?Python Node.fdToNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mininet.node.Node
的用法示例。
在下文中一共展示了Node.fdToNode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: monitor
# 需要导入模块: from mininet.node import Node [as 别名]
# 或者: from mininet.node.Node import fdToNode [as 别名]
def monitor( self, hosts=None, timeoutms=-1 ):
"""Monitor a set of hosts (or all hosts by default),
and return their output, a line at a time.
hosts: (optional) set of hosts to monitor
timeoutms: (optional) timeout value in ms
returns: iterator which returns host, line"""
if hosts is None:
hosts = self.hosts
poller = select.poll()
Node = hosts[ 0 ] # so we can call class method fdToNode
for host in hosts:
poller.register( host.stdout )
while True:
ready = poller.poll( timeoutms )
for fd, event in ready:
host = Node.fdToNode( fd )
if event & select.POLLIN:
line = host.readline()
if line is not None:
yield host, line
# Return if non-blocking
if not ready and timeoutms >= 0:
yield None, None