class_docstr: Scheduler extension - server side of MemorySampler
class_docstr_tok: ["Scheduler","extension","-","server","side","of","MemorySampler"]
docstr: Stop sampling and return the samples
docstr_tok: ["Stop","sampling","and","return","the","samples"]
code: def stop(self, key: str) -> list[tuple[float, int]]:
      """Stop sampling and return the samples"""
      pc = self.scheduler.periodic_callbacks.pop(
          "MemorySampler-" + key, None
      )
      if pc is not None:  # Race condition with scheduler shutdown
          pc.stop()
      return self.samples.pop(key)
  
file_path: distributed/distributed/diagnostics/memory_sampler.py
imports: from __future__ import annotations
  import uuid
  from collections.abc import AsyncIterator, Iterator
  from contextlib import asynccontextmanager, contextmanager
  from datetime import datetime
  from typing import TYPE_CHECKING, Any
  from distributed.compatibility import PeriodicCallback
label_desc: Use image node_id 3 for calling the MemorySamplerExtension obj's underlying member method code with example usage: obj.stop(key) and returns: self