Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion asynq/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 8 additions & 0 deletions asynq/tests/test_asynq_to_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down