4 ms·
How can this work: asyncio.create_task(myfunc()) # Python with asyncio Surely it would then call `myfunc` in the main thread, block until it b
by Blikkentrekker 6y ago
How can this work:
asyncio.create_task(myfunc()) # Python with asyncio
Surely it would then call `myfunc` in the main thread, block until it be done, then return whatever value it returns if it return at all, and call `create_task` with that value in the event that it return?
- incrudible 6y agoIt is implied that myfunc returns an awaitable object, not its ultimate result.
- pansa2 6y agoIIUC if `myfunc` is an async function, calling it will immediately return a coroutine object. None of the function’s code will run until it is `await`ed. (Unlike some other languages, async-await in Python is not “synchronous to the first await”.)