Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

# 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
Source by github.com #
 
PREVIOUS NEXT
Tagged: #async #await #function
ADD COMMENT
Topic
Name
9+1 =