Skip to content

Commit b1cef68

Browse files
committed
fix await for futures; see #712
1 parent ee6235b commit b1cef68

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

Diff for: custom_components/pyscript/eval.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2022,7 +2022,7 @@ async def ast_formattedvalue(self, arg):
20222022
async def ast_await(self, arg):
20232023
"""Evaluate await expr."""
20242024
coro = await self.aeval(arg.value)
2025-
if coro and asyncio.iscoroutine(coro):
2025+
if coro and (asyncio.iscoroutine(coro) or asyncio.isfuture(coro)):
20262026
return await coro
20272027
return coro
20282028

Diff for: tests/test_unit_eval.py

+10
Original file line numberDiff line numberDiff line change
@@ -1472,6 +1472,16 @@ async def handler():
14721472
""",
14731473
[20, 20],
14741474
],
1475+
[
1476+
"""
1477+
import asyncio
1478+
1479+
future = asyncio.Future()
1480+
future.set_result(True)
1481+
await future
1482+
""",
1483+
True,
1484+
],
14751485
]
14761486

14771487

0 commit comments

Comments
 (0)