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


Python DeviceTestServer.set_concurrency_options方法代码示例

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


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

示例1: test_AsyncClientIntegratedBase

# 需要导入模块: from katcp.testutils import DeviceTestServer [as 别名]
# 或者: from katcp.testutils.DeviceTestServer import set_concurrency_options [as 别名]
class test_AsyncClientIntegratedBase(TimewarpAsyncTestCase):
    def setUp(self):
        super(test_AsyncClientIntegratedBase, self).setUp()
        self.server = DeviceTestServer('localhost', 0)
        self.server.set_ioloop(self.io_loop)
        self.server.set_concurrency_options(thread_safe=False, handler_thread=False)
        self.server.start()

        host, port = self.server.bind_address
        logger.info('host, port: {}:{}'.format(host, port))
        self.client = katcp.CallbackClient(host, port)
        self.client.set_ioloop(self.io_loop)
开发者ID:ska-sa,项目名称:katcp-python,代码行数:14,代码来源:test_client.py

示例2: test_AsyncClientIntegrated

# 需要导入模块: from katcp.testutils import DeviceTestServer [as 别名]
# 或者: from katcp.testutils.DeviceTestServer import set_concurrency_options [as 别名]
class test_AsyncClientIntegrated(tornado.testing.AsyncTestCase, TestUtilMixin):
    def setUp(self):
        super(test_AsyncClientIntegrated, self).setUp()
        self.server = DeviceTestServer('', 0)
        self.server.set_ioloop(self.io_loop)
        self.server.set_concurrency_options(thread_safe=False, handler_thread=False)
        self.server.start()

        host, port = self.server.bind_address
        self.client = katcp.CallbackClient(host, port)
        self.client.set_ioloop(self.io_loop)
        self.client.start()

    @tornado.testing.gen_test
    def test_future_request_simple(self):
        yield self.client.until_connected()
        reply, informs = yield self.client.future_request(Message.request('watchdog'))
        self.assertEqual(len(informs), 0)
        self.assertEqual(reply.name, "watchdog")
        self.assertEqual(reply.arguments, ["ok"])

    @tornado.testing.gen_test
    def test_future_request_with_informs(self):
        yield self.client.until_connected()
        reply, informs = yield self.client.future_request(Message.request('help'))
        self.assertEqual(reply.name, "help")
        self.assertEqual(reply.arguments, ["ok", "%d" % NO_HELP_MESSAGES])
        self.assertEqual(len(informs), NO_HELP_MESSAGES)

    @tornado.testing.gen_test
    def test_disconnect_cleanup(self):
        yield self.client.until_protocol()
        mid = 55
        future_reply = self.client.future_request(Message.request(
            'slow-command', 1, mid=mid))
        # Force a disconnect
        self.client._disconnect()
        reply, informs = yield future_reply
        self.assertEqual(reply, Message.reply(
            'slow-command', 'fail', 'Connection closed before reply was received',
            mid=mid))

    @tornado.testing.gen_test
    def test_stop_cleanup(self):
        yield self.client.until_protocol()
        mid = 564
        future_reply = self.client.future_request(Message.request(
            'slow-command', 1, mid=mid))
        # Stop client
        self.client.stop()
        reply, informs = yield future_reply
        self.assertEqual(reply, Message.reply(
            'slow-command', 'fail', 'Client stopped before reply was received', mid=mid))
开发者ID:mmphego,项目名称:katcp-python,代码行数:55,代码来源:test_client.py

示例3: test_AsyncClientTimeoutsIntegrated

# 需要导入模块: from katcp.testutils import DeviceTestServer [as 别名]
# 或者: from katcp.testutils.DeviceTestServer import set_concurrency_options [as 别名]
class test_AsyncClientTimeoutsIntegrated(TimewarpAsyncTestCase):
    def setUp(self):
        super(test_AsyncClientTimeoutsIntegrated, self).setUp()
        self.server = DeviceTestServer('', 0)
        self.server.set_ioloop(self.io_loop)
        self.server.set_concurrency_options(thread_safe=False, handler_thread=False)
        self.server.start()

        host, port = self.server.bind_address
        self.client = katcp.CallbackClient(host, port)
        self.client.set_ioloop(self.io_loop)
        self.client.start()


    @tornado.testing.gen_test(timeout=10)
    # We are using time-warping, so the timeout should be longer than the fake-duration
    def test_future_request_default_timeout(self):
        # Test the default timeout of 5s
        yield self._test_timeout(5)

    @tornado.testing.gen_test()
    def test_future_request_change_default_timeout(self):
        self.client._request_timeout = 3
        yield self._test_timeout(3)

    @tornado.testing.gen_test()
    def test_future_request_request_timeout(self):
        yield self._test_timeout(1, set_request_timeout=True)

    @gen.coroutine
    def _test_timeout(self, timeout, set_request_timeout=False):
        request_timeout = timeout if set_request_timeout else None
        yield self.client.until_connected()
        t0 = self.io_loop.time()
        reply_future = self.client.future_request(Message.request('slow-command', timeout + 1),
                                                  timeout=request_timeout)
        # Warp to just before the timeout expires and check that the future is not yet
        # resolved
        self.set_ioloop_time(t0 + timeout*0.9999)
        yield self.wake_ioloop()
        self.assertFalse(reply_future.done())
        # Warp to just after the timeout expires, and check that it gives us a timeout
        # error reply
        self.set_ioloop_time(t0 + timeout*1.0001)
        yield self.wake_ioloop()
        self.assertTrue(reply_future.done())
        reply, informs = reply_future.result()
        self.assertFalse(reply.reply_ok())
        self.assertRegexpMatches(
            reply.arguments[1],
            r"Request slow-command timed out after .* seconds.")
开发者ID:mmphego,项目名称:katcp-python,代码行数:53,代码来源:test_client.py

示例4: DeviceTestServer

# 需要导入模块: from katcp.testutils import DeviceTestServer [as 别名]
# 或者: from katcp.testutils.DeviceTestServer import set_concurrency_options [as 别名]
import signal

import tornado
import IPython

from katcp.testutils import DeviceTestServer

from katcp import resource_client, inspecting_client


log = logging.getLogger(__name__)

ioloop = tornado.ioloop.IOLoop.current()

d = DeviceTestServer("", 0)
d.set_concurrency_options(False, False)
d.set_ioloop(ioloop)
ioloop.add_callback(d.start)


def setup_resource_client():
    global rc
    print d.bind_address
    rc = resource_client.KATCPClientResource(dict(name="thething", address=d.bind_address, controlled=True))
    rc.start()


def printy(*args):
    print args

开发者ID:ska-sa,项目名称:katcp-python,代码行数:31,代码来源:drive_resource_client.py

示例5: TestDeviceServerClientIntegratedAsync

# 需要导入模块: from katcp.testutils import DeviceTestServer [as 别名]
# 或者: from katcp.testutils.DeviceTestServer import set_concurrency_options [as 别名]
class TestDeviceServerClientIntegratedAsync(TestDeviceServerClientIntegrated):
    def _setup_server(self):
        self.server = DeviceTestServer('', 0)
        self.server.set_concurrency_options(thread_safe=False, handler_thread=False)
        start_thread_with_cleanup(self, self.server, start_timeout=1)
开发者ID:ska-sa,项目名称:katcp-python,代码行数:7,代码来源:test_server.py


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