python类convert_yielded()的实例源码

twisted_test.py 文件源码 项目:My-Web-Server-Framework-With-Python2.7 作者: syjsu 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def test_success(self):
        @inlineCallbacks
        def fn():
            if False:
                # inlineCallbacks doesn't work with regular functions;
                # must have a yield even if it's unreachable.
                yield
            returnValue(42)
        f = gen.convert_yielded(fn())
        self.assertEqual(f.result(), 42)
twisted_test.py 文件源码 项目:My-Web-Server-Framework-With-Python2.7 作者: syjsu 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
def test_failure(self):
        @inlineCallbacks
        def fn():
            if False:
                yield
            1 / 0
        f = gen.convert_yielded(fn())
        with self.assertRaises(ZeroDivisionError):
            f.result()
twisted_test.py 文件源码 项目:annotated-py-tornado 作者: hhstore 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def test_success(self):
        @inlineCallbacks
        def fn():
            if False:
                # inlineCallbacks doesn't work with regular functions;
                # must have a yield even if it's unreachable.
                yield
            returnValue(42)
        f = gen.convert_yielded(fn())
        self.assertEqual(f.result(), 42)
twisted_test.py 文件源码 项目:annotated-py-tornado 作者: hhstore 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def test_failure(self):
        @inlineCallbacks
        def fn():
            if False:
                yield
            1 / 0
        f = gen.convert_yielded(fn())
        with self.assertRaises(ZeroDivisionError):
            f.result()
twisted_test.py 文件源码 项目:annotated-py-tornado 作者: hhstore 项目源码 文件源码 阅读 38 收藏 0 点赞 0 评论 0
def test_success(self):
        @inlineCallbacks
        def fn():
            if False:
                # inlineCallbacks doesn't work with regular functions;
                # must have a yield even if it's unreachable.
                yield
            returnValue(42)
        f = gen.convert_yielded(fn())
        self.assertEqual(f.result(), 42)
twisted_test.py 文件源码 项目:annotated-py-tornado 作者: hhstore 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def test_failure(self):
        @inlineCallbacks
        def fn():
            if False:
                yield
            1 / 0
        f = gen.convert_yielded(fn())
        with self.assertRaises(ZeroDivisionError):
            f.result()
twisted_test.py 文件源码 项目:projects-2017-2 作者: ncss 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def test_success(self):
        @inlineCallbacks
        def fn():
            if False:
                # inlineCallbacks doesn't work with regular functions;
                # must have a yield even if it's unreachable.
                yield
            returnValue(42)
        f = gen.convert_yielded(fn())
        self.assertEqual(f.result(), 42)
twisted_test.py 文件源码 项目:projects-2017-2 作者: ncss 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def test_failure(self):
        @inlineCallbacks
        def fn():
            if False:
                yield
            1 / 0
        f = gen.convert_yielded(fn())
        with self.assertRaises(ZeroDivisionError):
            f.result()
twisted_test.py 文件源码 项目:aweasome_learning 作者: Knight-ZXW 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def test_success(self):
        @inlineCallbacks
        def fn():
            if False:
                # inlineCallbacks doesn't work with regular functions;
                # must have a yield even if it's unreachable.
                yield
            returnValue(42)
        f = gen.convert_yielded(fn())
        self.assertEqual(f.result(), 42)
twisted_test.py 文件源码 项目:aweasome_learning 作者: Knight-ZXW 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def test_failure(self):
        @inlineCallbacks
        def fn():
            if False:
                yield
            1 / 0
        f = gen.convert_yielded(fn())
        with self.assertRaises(ZeroDivisionError):
            f.result()
twisted_test.py 文件源码 项目:zenchmarks 作者: squeaky-pl 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def test_success(self):
        @inlineCallbacks
        def fn():
            if False:
                # inlineCallbacks doesn't work with regular functions;
                # must have a yield even if it's unreachable.
                yield
            returnValue(42)
        f = gen.convert_yielded(fn())
        self.assertEqual(f.result(), 42)
twisted_test.py 文件源码 项目:zenchmarks 作者: squeaky-pl 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def test_failure(self):
        @inlineCallbacks
        def fn():
            if False:
                yield
            1 / 0
        f = gen.convert_yielded(fn())
        with self.assertRaises(ZeroDivisionError):
            f.result()
twisted_test.py 文件源码 项目:browser_vuln_check 作者: lcatro 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def test_success(self):
        @inlineCallbacks
        def fn():
            if False:
                # inlineCallbacks doesn't work with regular functions;
                # must have a yield even if it's unreachable.
                yield
            returnValue(42)
        f = gen.convert_yielded(fn())
        self.assertEqual(f.result(), 42)
twisted_test.py 文件源码 项目:browser_vuln_check 作者: lcatro 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
def test_failure(self):
        @inlineCallbacks
        def fn():
            if False:
                yield
            1 / 0
        f = gen.convert_yielded(fn())
        with self.assertRaises(ZeroDivisionError):
            f.result()
twisted_test.py 文件源码 项目:PyQYT 作者: collinsctk 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def test_success(self):
        @inlineCallbacks
        def fn():
            if False:
                # inlineCallbacks doesn't work with regular functions;
                # must have a yield even if it's unreachable.
                yield
            returnValue(42)
        f = gen.convert_yielded(fn())
        self.assertEqual(f.result(), 42)
twisted_test.py 文件源码 项目:PyQYT 作者: collinsctk 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def test_failure(self):
        @inlineCallbacks
        def fn():
            if False:
                yield
            1 / 0
        f = gen.convert_yielded(fn())
        with self.assertRaises(ZeroDivisionError):
            f.result()
handler.py 文件源码 项目:inmanta 作者: inmanta 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def run_sync(self, func: typing.Callable) -> typing.Any:
        """
            Run a the given async function on the ioloop of the agent. It will block the current thread until the future
            resolves.

            :param func: A function that returns a yieldable future.
            :return: The result of the async function.
        """
        f = Future()

        def future_to_future(future):
            exc = future.exception()
            if exc is not None:
                f.set_exception(exc)
            else:
                f.set_result(future.result())

        def run():
            try:
                result = func()
                if result is not None:
                    from tornado.gen import convert_yielded
                    result = convert_yielded(result)
                    result.add_done_callback(future_to_future)
            except Exception as e:
                f.set_exception(e)
        self._ioloop.add_callback(run)

        return f.result()
main.py 文件源码 项目:inmanta 作者: inmanta 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def run_sync(self, func):
        if self._own_loop:
            return self._io_loop.run_sync(func)

        else:
            f = Future()

            def future_to_future(future):
                exc = future.exception()
                if exc is not None:
                    f.set_exception(exc)
                else:
                    f.set_result(future.result())

            def run():
                try:
                    result = func()
                    if result is not None:
                        from tornado.gen import convert_yielded
                        result = convert_yielded(result)
                        result.add_done_callback(future_to_future)
                except Exception as e:
                    f.set_exception(e)
            self._io_loop.add_callback(run)

            return f.result()
twisted_test.py 文件源码 项目:ProgrameFacil 作者: Gpzim98 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def test_success(self):
        @inlineCallbacks
        def fn():
            if False:
                # inlineCallbacks doesn't work with regular functions;
                # must have a yield even if it's unreachable.
                yield
            returnValue(42)
        f = gen.convert_yielded(fn())
        self.assertEqual(f.result(), 42)
twisted_test.py 文件源码 项目:ProgrameFacil 作者: Gpzim98 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def test_failure(self):
        @inlineCallbacks
        def fn():
            if False:
                yield
            1 / 0
        f = gen.convert_yielded(fn())
        with self.assertRaises(ZeroDivisionError):
            f.result()


问题


面经


文章

微信
公众号

扫码关注公众号