title: asyncio - wait for each task in a dynamic list to finish or be cancelled
body: <p>I have a list of asyncio tasks: <code>[task1, task2, task3]</code>. And each task can append more tasks to this list, e.g., <code>task3</code> might append <code>task4</code>.</p>
  
  <p>How can I wait for all tasks in this dynamic list to finish or be cancelled?</p>
  
  <p>I tried <code>await asyncio.gather(*[task1, task2, task3])</code>, but it doesn't wait for tasks created by <code>task1</code>, <code>task2</code> or <code>task3</code>.</p>