title: Async queue for slots availability
body: <p>I am trying to do a manager for users with slots. What it has to do it's to &quot;open&quot; 10 slots and when a user what to make the task first it has to check availability if it's an free slots the user can do the task.</p>
  <p>I mean, I have 10 slots, there is 9 users doing the task so the new one that arrives can occupied the last slot but if after this a new user comes a want to do the task it's refused.
  If the user ask again in the future and another users has finish the task he will be able to do it.</p>
  <p>I have tried with the code</p>
  <pre><code>import asyncio
  
  
  async def worker(name, queue):
      while True:
          # Get a &quot;work item&quot; out of the queue.
          user_id = await queue.get()
          # Sleep for 1second.
          await asyncio.sleep(1)
          # Notify the queue that the &quot;work item&quot; has been processed.
          queue.task_done()
  
          print(f'Worker {name} has the user id {user_id}')
  
  
  async def main():
      # Create a queue that we will use to store our &quot;workload&quot;.
      queue = asyncio.Queue()
  
      # Create worker tasks to process the queue concurrently.
      tasks = []
      for i in range(10):
          task = asyncio.create_task(worker(f'worker-{i}', queue))
          tasks.append(task)
  
  
      # Generate random timings and put them into the queue.
      total_sleep_time = 0
      for _ in range(2):
          await queue.put(_)
  
      await queue.join()
  
  asyncio.run(main())
  </code></pre>
  <p>But It's impossible to run the queu without user the queue.join() so the list it's not dynamically modified.</p>
  <p>Sorry for my english and I hope I have explained well the little function.</p>
  <p>Thanks a lot.</p>