'How to change control from async function to main code back to async function?
Is it possible to change the control from one async function to another or from one async function to a sync function?
import asyncio
def main():
print("Beginning")
asyncio.run(async_func())
print ("Middle")
print("End")
async def async_func():
print(1)
await asyncio.sleep(1)
# I want to print "Middle" during this
print(2)
await asyncio.sleep(1)
# I want to print "End" during this
print(3)
main()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
