当前位置: 首页>>代码示例>>Python>>正文


Python WebLabDeustoClient.send_async_command方法代码示例

本文整理汇总了Python中weblab.core.coordinator.clients.weblabdeusto.WebLabDeustoClient.send_async_command方法的典型用法代码示例。如果您正苦于以下问题:Python WebLabDeustoClient.send_async_command方法的具体用法?Python WebLabDeustoClient.send_async_command怎么用?Python WebLabDeustoClient.send_async_command使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在weblab.core.coordinator.clients.weblabdeusto.WebLabDeustoClient的用法示例。


在下文中一共展示了WebLabDeustoClient.send_async_command方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: IntegrationNoConcurrencyTestCase

# 需要导入模块: from weblab.core.coordinator.clients.weblabdeusto import WebLabDeustoClient [as 别名]
# 或者: from weblab.core.coordinator.clients.weblabdeusto.WebLabDeustoClient import send_async_command [as 别名]

#.........这里部分代码省略.........
        short_time = 0.1

        # Time extended from 9.0 to 15.0 because at times the test failed, possibly for that reason.
        times      = 15.0 / short_time

        while times > 0:
            new_status = self.client.get_reservation_status(reservation_id)
            if not isinstance(new_status, Reservation.WaitingConfirmationReservation) and not isinstance(new_status, Reservation.WaitingReservation):
                break
            times -= 1
            time.sleep(short_time)
        reservation = self.client.get_reservation_status(reservation_id)
        self.assertTrue(
                isinstance(reservation, Reservation.ConfirmedReservation),
                "Reservation %s is not Confirmed, as expected by this time" % reservation
            )
        return session_id, reservation_id

    def _single_async_use(self, logout = True):
        session_id, reservation_id = self._get_reserved()

        # send the program again, but asynchronously. Though this should work, it is not really very customary
        # to send_file more than once in the same session. In fact, it is a feature which might get removed in
        # the future. When/if that happens, this will need to be modified.
        CONTENT = "content of the program FPGA"
        reqid = self.client.send_async_file(reservation_id, ExperimentUtil.serialize(CONTENT), 'program')

        # Wait until send_async_file query is actually finished.
        #self._get_async_response(session_id, reqid)
        self._wait_async_done(reservation_id, (reqid,))

        # We need to wait for the programming to finish, while at the same
        # time making sure that the tests don't dead-lock.
        reqid = self.client.send_async_command(reservation_id, Command.Command("STATE"))
        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:
开发者ID:zstars,项目名称:weblabdeusto,代码行数:70,代码来源:test_no_concurrency.py


注:本文中的weblab.core.coordinator.clients.weblabdeusto.WebLabDeustoClient.send_async_command方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。