You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you want to implement this feature, comment to let us know (we'll work with you on design, scheduling, etc.)
Issue details
Pulumi Python SDK carries logic in sync_await.py that is non-trivial and seems to overlap with the https://github.com/erdewit/nest_asyncio library. If this makes sense for the project, it could be nice to re-use and delegate to nest_asyncio.
Illustration:
importasyncioimportnest_asyncionest_asyncio.apply()
defdo_sync(another_task):
# it is not normally possible to await an aio task inside a def# that is not yet async, like this one, when this def is invoked# from a task itself. What one gets in standard Python is:## raise RuntimeError('This event loop is already running')## Pulumi introduecs _sync_await to fix this.## The alternative is to enable `nest_asyncio` that makes# `run_until_complete` work as expected.loop=asyncio.get_event_loop()
returnloop.run_until_complete(another_task)
asyncdefdo_io(another_task):
print('io start')
awaitasyncio.sleep(5)
result=do_sync(another_task)
print(f'result = {result}')
print('io end')
asyncdefdo_other_things():
print('doing other things')
return'other things'loop=asyncio.get_event_loop()
f1=loop.create_task(do_other_things())
f2=loop.create_task(do_io(f1))
loop.run_until_complete(f1)
loop.run_until_complete(f2)
loop.close()
Affected area/feature
Python
The text was updated successfully, but these errors were encountered:
Hello!
Issue details
Pulumi Python SDK carries logic in
sync_await.py
that is non-trivial and seems to overlap with the https://github.com/erdewit/nest_asyncio library. If this makes sense for the project, it could be nice to re-use and delegate to nest_asyncio.Illustration:
Affected area/feature
Python
The text was updated successfully, but these errors were encountered: