Ejemplo n.º 1
0
    def async_add_job(self, target, *args):
        """Add job from within the event loop."""
        task = None

        if asyncio.iscoroutine(target):
            task = self.loop.create_task(target)
        elif util.is_callback(target):
            self.loop.call_soon(target, *args)
        elif util.iscoro(target):
            task = self.loop.create_task(target(*args))
        else:
            task = self.loop.run_in_executor(None, target, *args)

        return task
Ejemplo n.º 2
0
def test_callback():
    """Test is_callback."""
    assert util.is_callback(async_is_callback) is True
    assert util.is_callback(async_not_callback) is False