This gathers ``TaskState`` metadata and final state from the scheduler for tasks which are submitted and finished within the scope of this context manager.
>>> with get_task_metadata() as tasks:
... x.compute()
>>> tasks.metadata
{...}
>>> tasks.state
{...}