code: def on_task_done(
      self, t: asyncio.Task
  ) -> Callable[[asyncio.Future], None]:
      def callback(fut: asyncio.Future):
          self.tasks.remove(t)
          try:
              if e := fut.exception():
                  log.exception(e)
          except asyncio.CancelledError:
              if not self._closed:
                  log.exception(
                      "Background task was cancelled before task manager shutdown"
                  )
  
      return callback
  
file_path: hail/hail/python/hailtop/aiotools/tasks.py
imports: from typing import Callable, Set
  import asyncio
  import logging
label_desc: Use image node_id 3 for calling the BackgroundTaskManager obj's underlying member method code with example usage: obj.on_task_done(t) and returns: callback