Blame view

4_100k_coros.py 383 Bytes
444c887a   Lars Tiede   first commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
  #!/usr/bin/env python
  import asyncio
  
  finished_count = 0
  
  
  
  async def slow_op(n):
      global finished_count
      await asyncio.sleep(1)
      finished_count += 1
  
  
  async def main():
      await asyncio.wait([
          slow_op(i) for i in range(100 * 1000)
          ])
  
  
  
  
  
  
  loop = asyncio.get_event_loop()
  loop.run_until_complete(main())
  print("finished_count = {}".format(finished_count))