From 23dbd19cbd99a06b341ac5df861d50fc0518c1c3 Mon Sep 17 00:00:00 2001 From: Ivan Levkivskyi Date: Fri, 6 Jun 2025 22:24:33 +0000 Subject: [PATCH 1/2] Fix .asyncio() on async_proxy returning ConstFuture --- asynq/decorators.py | 5 ++++- asynq/tests/test_asynq_to_async.py | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) 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..da15081 100644 --- a/asynq/tests/test_asynq_to_async.py +++ b/asynq/tests/test_asynq_to_async.py @@ -201,6 +201,12 @@ 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): From e481057b027def495fc66212858e4a70ae30a68c Mon Sep 17 00:00:00 2001 From: Ivan Levkivskyi Date: Fri, 6 Jun 2025 22:33:44 +0000 Subject: [PATCH 2/2] black --- asynq/tests/test_asynq_to_async.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/asynq/tests/test_asynq_to_async.py b/asynq/tests/test_asynq_to_async.py index da15081..8cc29a5 100644 --- a/asynq/tests/test_asynq_to_async.py +++ b/asynq/tests/test_asynq_to_async.py @@ -201,6 +201,7 @@ def f1(): assert asyncio.run(f1.asyncio()) == 100 + def test_proxy_const(): @asynq.async_proxy() def f1(): @@ -208,6 +209,7 @@ def f1(): assert asyncio.run(f1.asyncio()) == 42 + def test_proxy_and_bind(): async def async_g(self, x): return x + 20 + B.SELF