本文整理汇总了Python中weblab.core.coordinator.clients.weblabdeusto.WebLabDeustoClient.check_async_command_status方法的典型用法代码示例。如果您正苦于以下问题:Python WebLabDeustoClient.check_async_command_status方法的具体用法?Python WebLabDeustoClient.check_async_command_status怎么用?Python WebLabDeustoClient.check_async_command_status使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类weblab.core.coordinator.clients.weblabdeusto.WebLabDeustoClient
的用法示例。
在下文中一共展示了WebLabDeustoClient.check_async_command_status方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: IntegrationNoConcurrencyTestCase
# 需要导入模块: from weblab.core.coordinator.clients.weblabdeusto import WebLabDeustoClient [as 别名]
# 或者: from weblab.core.coordinator.clients.weblabdeusto.WebLabDeustoClient import check_async_command_status [as 别名]
#.........这里部分代码省略.........
respcmd = self._get_async_response(reservation_id, reqid)
response = respcmd.get_command_string()
# Check that the current state is "Ready"
self.assertEquals("STATE", response)
reqid = self.client.send_async_command(reservation_id, Command.Command("ChangeSwitch on 0"))
self._wait_async_done(reservation_id, (reqid,))
reqid = self.client.send_async_command(reservation_id, Command.Command("ClockActivation on 250"))
self._wait_async_done(reservation_id, (reqid,))
if logout:
self.client.logout(session_id)
def _wait_async_done(self, reservation_id, reqids):
"""
_wait_async_done(session_id, reqids)
Helper methods that waits for the specified asynchronous requests to be finished,
and which asserts that they were successful. Note that it doesn't actually return
their responses.
@param reqids Tuple containing the request ids for the commands to check.
@return Nothing
"""
# Wait until send_async_file query is actually finished.
reqsl = list(reqids)
max_count = 15
while len(reqsl) > 0:
time.sleep(0.1)
max_count -= 1
if max_count == 0:
raise Exception("Maximum time spent waiting async done")
requests = self.client.check_async_command_status(reservation_id, tuple(reqsl))
self.assertEquals(len(reqsl), len(requests))
for rid, req in six.iteritems(requests):
status = req[0]
self.assertTrue(status in ("running", "ok", "error"))
if status != "running":
self.assertEquals("ok", status, "Contents: " + req[1])
reqsl.remove(rid)
def _get_async_response(self, reservation_id, reqid):
"""
_get_async_response(reqids)
Helper method that synchronously gets the response for the specified async request, asserting that
it was successful.
@param reqid The request identifier for the async request whose response we want
@return Response to the request, if successful. None, otherwise.
"""
# Wait until send_async_file query is actually finished.
max_counter = 15
while True:
max_counter -= 1
if max_counter == 0:
raise Exception("Maximum times running get_async_response")
time.sleep(0.1)
requests = self.client.check_async_command_status(reservation_id, (reqid,))
self.assertEquals(1, len(requests))
self.assertTrue(reqid in requests)
req = requests[reqid]
status = req[0]
self.assertTrue(status in ("running", "ok", "error"))
if status != "running":
self.assertEquals("ok", status, "Contents: " + req[1])
return Command.Command(req[1])