diff --git a/asynq/decorators.py b/asynq/decorators.py index 5396788..5961f0d 100644 --- a/asynq/decorators.py +++ b/asynq/decorators.py @@ -271,7 +271,10 @@ def asyncio(self, *args, **kwargs) -> Coroutine[Any, Any, Any]: asyncio_fn = convert_asynq_to_async(self.fn) async def unwrap_coroutine(*args, **kwargs): - return await (await asyncio_fn(*args, **kwargs)) + fut = await asyncio_fn(*args, **kwargs) + if isinstance(fut, futures.ConstFuture): + return fut.value() + return await fut self.asyncio_fn = unwrap_coroutine diff --git a/asynq/tests/test_asynq_to_async.py b/asynq/tests/test_asynq_to_async.py index e472644..8cc29a5 100644 --- a/asynq/tests/test_asynq_to_async.py +++ b/asynq/tests/test_asynq_to_async.py @@ -202,6 +202,14 @@ def f1(): assert asyncio.run(f1.asyncio()) == 100 +def test_proxy_const(): + @asynq.async_proxy() + def f1(): + return asynq.ConstFuture(42) + + assert asyncio.run(f1.asyncio()) == 42 + + def test_proxy_and_bind(): async def async_g(self, x): return x + 20 + B.SELF