示例#1
0
    def await_(self, coroutine):
        """Run given asynchronous coroutine to completion.
        This prevents a warning from being emitted when it goes out of scope.

        :param coroutine: A coroutine or a coroutine function
        """
        self.assertIsNotNone(
            asyncio, msg="Tried to use asyncio on unsupported Python version")

        loop = asyncio.new_event_loop()
        if asyncio.iscoroutinefunction(coroutine):
            coroutine = coroutine(loop)
        loop.run_until_complete(coroutine)
        loop.close()

        return coroutine
示例#2
0
文件: __init__.py 项目: Xion/callee
    def await_(self, coroutine):
        """Run given asynchronous coroutine to completion.
        This prevents a warning from being emitted when it goes out of scope.

        :param coroutine: A coroutine or a coroutine function
        """
        self.assertIsNotNone(
            asyncio,
            msg="Tried to use asyncio on unsupported Python version")

        loop = asyncio.new_event_loop()
        if asyncio.iscoroutinefunction(coroutine):
            coroutine = coroutine(loop)
        loop.run_until_complete(coroutine)
        loop.close()

        return coroutine
示例#3
0
文件: functions.py 项目: Xion/callee
 def match(self, value):
     return asyncio and asyncio.iscoroutinefunction(value)
示例#4
0
 def match(self, value):
     return asyncio and asyncio.iscoroutinefunction(value)