You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
381 B
Python
21 lines
381 B
Python
7 years ago
|
import asyncio
|
||
|
|
||
|
|
||
|
async def hello_async():
|
||
|
print('Hello Async!')
|
||
|
|
||
|
|
||
|
async def hello_python():
|
||
|
print('Hello Python')
|
||
|
await asyncio.sleep(0.1)
|
||
|
|
||
|
event_loop = asyncio.get_event_loop()
|
||
|
try:
|
||
|
result = event_loop.run_until_complete(asyncio.gather(
|
||
|
hello_async(),
|
||
|
hello_python(),
|
||
|
hello_python(),
|
||
|
))
|
||
|
print(result)
|
||
|
finally:
|
||
|
event_loop.close()
|