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