Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. import asyncio
  2. import time
  3.  
  4.  
  5. async def call1(x, y, z):
  6. await asyncio.sleep(1)
  7. print(x, y, z)
  8.  
  9. def call2(x, y, z):
  10. time.sleep(1)
  11. print(x, y, z)
  12.  
  13.  
  14. def wrapper(func, *args):
  15. if asyncio.iscoroutinefunction(func):
  16. asyncio.get_event_loop().run_until_complete(func(*args))
  17. else:
  18. func(*args)
  19.  
  20.  
  21. if __name__ == '__main__':
  22. wrapper(call1, 1, 2, 3)
  23. wrapper(call2, 1, 2, 3)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement