I use asyncio
event loop which is a kind of performing asynchronous/concurrency tasks in Python3.x .
Is there any equivalent of asyncio
(async/await) or coroutines in Go lang on a thread only?
[NOTE]:
Not parallelism + concurrency
(multiprocessing) pattern.
[UPDATE]:
Here is an asynchronous event loop using asyncio
in Python for better sense:
import asyncio
import time
async def async_say(delay, msg):
await asyncio.sleep(delay)
print(msg)
async def main():
task1 = asyncio.ensure_future(async_say(4, 'hello'))
task2 = asyncio.ensure_future(async_say(6, 'world'))
print(f"started at {time.strftime('%X')}")
await task1
await task2
print(f"finished at {time.strftime('%X')}")
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
Out:
started at 13:19:44
hello
world
finished at 13:19:50
Any help would be greatly appreciated.