Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b1cef68

Browse files
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

‎custom_components/pyscript/eval.py‎

Lines changed: 1 addition & 1 deletion
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) orasyncio.isfuture(coro)):
20262026
return await coro
20272027
return coro
20282028

‎tests/test_unit_eval.py‎

Lines changed: 10 additions & 0 deletions
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)

AltStyle によって変換されたページ (->オリジナル) /