title: Is it possible to limit the number of coroutines running corcurrently in asyncio?
body: <p>I already wrote my script using asyncio but found that the number of coroutines running simultaneously is too large and it often ends up hanging around.</p>
  
  <p>So I would like to limit the number of coroutines concurrently, and once it reaches the limit, I want to wait for any coroutine to be finished before another is executed.</p>
  
  <p>My current code is something like the following:</p>
  
  <pre><code>loop = asyncio.get_event_loop()
  p = map(my_func, players)
  result = loop.run_until_complete(asyncio.gather(*p))
  
  async def my_func(player):
      # something done with `await`
  </code></pre>
  
  <p>The <code>players</code> is of type <code>list</code> and contains many elements (say, 12000). It needs so much computational resource to run all of them simultaneously in <code>asyncio.gather(*p)</code> so I would rather like the number of players run simultaneously to be 200. Once it reaches 199, then I wish another coroutine starts to be executed.</p>
  
  <p>Is this possible in asyncio?</p>