Exemplo n.º 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
Exemplo n.º 2
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
Exemplo n.º 3
0
 def match(self, value):
     return asyncio and asyncio.iscoroutinefunction(value)
Exemplo n.º 4
0
 def match(self, value):
     return asyncio and asyncio.iscoroutinefunction(value)