Call function async

Code examples

0
0

# async await function

# async await function
import asyncio
import time
async def sleep_6():
  time.sleep(5)
  print('5 done')
  time.sleep(3)
  print('3 done')
  
async def sleep_8():
  await asyncio.sleep(7)
  print('8 done')

async def gather_fxn():
  await asyncio.gather(sleep_6(), sleep_8())

loop=asyncio.new_event_loop()
loop=loop.run_until_complete(gather_fxn())
loop.close()

# output:
# 5 done
# 3 done
# 8 done

Similar pages

Similar pages with examples

In other languages

This page is in other languages

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................
Балгарскі
..................................................................................................................
Íslensk
..................................................................................................................