本文整理汇总了Python中vlcp.event.runnable.RoutineContainer.executeWithTimeout方法的典型用法代码示例。如果您正苦于以下问题:Python RoutineContainer.executeWithTimeout方法的具体用法?Python RoutineContainer.executeWithTimeout怎么用?Python RoutineContainer.executeWithTimeout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vlcp.event.runnable.RoutineContainer
的用法示例。
在下文中一共展示了RoutineContainer.executeWithTimeout方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: OpenflowPortManager
# 需要导入模块: from vlcp.event.runnable import RoutineContainer [as 别名]
# 或者: from vlcp.event.runnable.RoutineContainer import executeWithTimeout [as 别名]
#.........这里部分代码省略.........
else:
self.apiroutine.retvalue = [(dpid, p, vh) for (vh, dpid),v in self.managed_ports.items() if vh == vhost for p in v.values()]
def getportbyno(self, datapathid, portno, vhost = ''):
"Return port with specified portno"
for m in self._wait_for_sync():
yield m
self.apiroutine.retvalue = self._getportbyno(datapathid, portno, vhost)
def _getportbyno(self, datapathid, portno, vhost = ''):
ports = self.managed_ports.get((vhost, datapathid))
if ports is None:
return None
else:
return ports.get(portno)
def waitportbyno(self, datapathid, portno, timeout = 30, vhost = ''):
for m in self._wait_for_sync():
yield m
def waitinner():
ports = self.managed_ports.get((vhost, datapathid))
if ports is None:
for m in callAPI(self.apiroutine, 'openflowmanager', 'waitconnection', {'datapathid': datapathid, 'vhost':vhost, 'timeout': timeout}):
yield m
c = self.apiroutine.retvalue
ports = self.managed_ports.get((vhost, datapathid))
if ports is None:
yield (OpenflowPortSynchronized.createMatcher(c),)
ports = self.managed_ports.get((vhost, datapathid))
if ports is None:
raise ConnectionResetException('Datapath %016x is not connected' % datapathid)
if portno not in ports:
yield (OpenflowAsyncMessageEvent.createMatcher(of13.OFPT_PORT_STATUS, datapathid, 0, _ismatch = lambda x: x.message.desc.port_no == portno),)
self.apiroutine.retvalue = self.apiroutine.event.message.desc
else:
self.apiroutine.retvalue = ports[portno]
for m in self.apiroutine.executeWithTimeout(timeout, waitinner()):
yield m
if self.apiroutine.timeout:
raise OpenflowPortNotAppearException('Port %d does not appear on datapath %016x' % (portno, datapathid))
def getportbyname(self, datapathid, name, vhost = ''):
"Return port with specified portno"
for m in self._wait_for_sync():
yield m
self.apiroutine.retvalue = self._getportbyname(datapathid, name, vhost)
def _getportbyname(self, datapathid, name, vhost = ''):
if not isinstance(name, bytes):
name = _bytes(name)
ports = self.managed_ports.get((vhost, datapathid))
if ports is None:
return None
else:
for p in ports.values():
if p.name == name:
return p
return None
def waitportbyname(self, datapathid, name, timeout = 30, vhost = ''):
for m in self._wait_for_sync():
yield m
if not isinstance(name, bytes):
name = _bytes(name)
def waitinner():
ports = self.managed_ports.get((vhost, datapathid))
if ports is None:
for m in callAPI(self.apiroutine, 'openflowmanager', 'waitconnection', {'datapathid': datapathid, 'vhost':vhost, 'timeout': timeout}):
yield m
c = self.apiroutine.retvalue
ports = self.managed_ports.get((vhost, datapathid))
if ports is None:
示例2: OVSDBPortManager
# 需要导入模块: from vlcp.event.runnable import RoutineContainer [as 别名]
# 或者: from vlcp.event.runnable.RoutineContainer import executeWithTimeout [as 别名]
#.........这里部分代码省略.........
def _getportbyno(self, datapathid, portno, vhost = ''):
ports = self.managed_ports.get((vhost, datapathid))
if ports is None:
return None
else:
for _, p in ports:
if p['ofport'] == portno:
return p
return None
def waitportbyno(self, datapathid, portno, timeout = 30, vhost = ''):
"Wait for port with specified portno"
portno &= 0xffff
for m in self._wait_for_sync():
yield m
def waitinner():
p = self._getportbyno(datapathid, portno, vhost)
if p is not None:
self.apiroutine.retvalue = p
else:
try:
self.wait_portnos[(vhost, datapathid, portno)] = \
self.wait_portnos.get((vhost, datapathid, portno),0) + 1
yield (OVSDBPortUpNotification.createMatcher(None, None, portno, None, vhost, datapathid),)
except:
v = self.wait_portnos.get((vhost, datapathid, portno))
if v is not None:
if v <= 1:
del self.wait_portnos[(vhost, datapathid, portno)]
else:
self.wait_portnos[(vhost, datapathid, portno)] = v - 1
raise
else:
self.apiroutine.retvalue = self.apiroutine.event.port
for m in self.apiroutine.executeWithTimeout(timeout, waitinner()):
yield m
if self.apiroutine.timeout:
raise OVSDBPortNotAppearException('Port ' + repr(portno) + ' does not appear before timeout')
def getportbyname(self, datapathid, name, vhost = ''):
"Return port with specified name"
if isinstance(name, bytes):
name = name.decode('utf-8')
for m in self._wait_for_sync():
yield m
self.apiroutine.retvalue = self._getportbyname(datapathid, name, vhost)
def _getportbyname(self, datapathid, name, vhost = ''):
ports = self.managed_ports.get((vhost, datapathid))
if ports is None:
return None
else:
for _, p in ports:
if p['name'] == name:
return p
return None
def waitportbyname(self, datapathid, name, timeout = 30, vhost = ''):
"Wait for port with specified name"
for m in self._wait_for_sync():
yield m
def waitinner():
p = self._getportbyname(datapathid, name, vhost)
if p is not None:
self.apiroutine.retvalue = p
else:
try:
self.wait_names[(vhost, datapathid, name)] = \
self.wait_portnos.get((vhost, datapathid, name) ,0) + 1
yield (OVSDBPortUpNotification.createMatcher(None, name, None, None, vhost, datapathid),)