class_docstr: Scheduler extension for spans support
class_docstr_tok: ["Scheduler","extension","for","spans","support"]
docstr: Return the currently active default span, or create one if the previous one
  terminated. In other words, do not reuse the previous default span if all tasks
  that were not explicitly annotated with :func:`spans` on the client side are
  finished.
docstr_tok: ["Return","the","currently","active","default","span",",","or","create","one","if","the","previous","one","terminated",".","In","other","words",",","do","not","reuse","the","previous","default","span","if","all","tasks","that","were","not","explicitly","annotated","with",":","func",":","`","spans","`","on","the","client","side","are","finished","."]
code: def _ensure_default_span(self) -> Span:
      """Return the currently active default span, or create one if the previous one
      terminated. In other words, do not reuse the previous default span if all tasks
      that were not explicitly annotated with :func:`spans` on the client side are
      finished.
      """
      defaults = self.spans_search_by_name["default",]
      if defaults and not defaults[-1].done:
          return defaults[-1]
      return self._ensure_span(("default",), (str(uuid.uuid4()),))
  
imports: from __future__ import annotations
  import uuid
  import weakref
  from collections import defaultdict
  from collections.abc import Hashable, Iterable, Iterator
  from contextlib import contextmanager
  from itertools import islice
  from typing import TYPE_CHECKING, Any
  import dask.config
  from dask.typing import Key
  from distributed.collections import sum_mappings
  from distributed.itertools import ffill
  from distributed.metrics import time
label_desc: Use image node_id 3 for calling the SpansSchedulerExtension obj's underlying member method code with example usage: obj._ensure_default_span() and returns: self, defaults