class_docstr: A process to manage worker processes
  
  The nanny spins up Worker processes, watches them, and kills or restarts
  them as necessary. It is necessary if you want to use the
  ``Client.restart`` method, or to restart the worker automatically if
  it gets to the terminate fraction of its memory limit.
  
  The parameters for the Nanny are mostly the same as those for the Worker
  with exceptions listed below.
  
  Parameters
  ----------
  env: dict, optional
      Environment variables set at time of Nanny initialization will be
      ensured to be set in the Worker process as well. This argument allows to
      overwrite or otherwise set environment variables for the Worker. It is
      also possible to set environment variables using the option
      ``distributed.nanny.environ``. Precedence as follows
  
          1. Nanny arguments
          2. Existing environment variables
          3. Dask configuration
  
      .. note::
         Some environment variables, like ``OMP_NUM_THREADS``, must be set before
         importing numpy to have effect. Others, like ``MALLOC_TRIM_THRESHOLD_`` (see
         :ref:`memtrim`), must be set before starting the Linux process. Such
         variables would be ineffective if set here or in
         ``distributed.nanny.environ``; they must be set in
         ``distributed.nanny.pre-spawn-environ`` so that they are set before spawning
         the subprocess, even if this means poisoning the process running the Nanny.
  
         For the same reason, be warned that changing
         ``distributed.worker.multiprocessing-method`` from ``spawn`` to ``fork`` or
         ``forkserver`` may inhibit some environment variables; if you do, you should
         set the variables yourself in the shell before you start ``dask-worker``.
  
  See Also
  --------
  Worker
class_docstr_tok: ["A","process","to","manage","worker","processes","The","nanny","spins","up","Worker","processes",",","watches","them",",","and","kills","or","restarts","them","as","necessary",".","It","is","necessary","if","you","want","to","use","the","``","Client.restart","``","method",",","or","to","restart","the","worker","automatically","if","it","gets","to","the","terminate","fraction","of","its","memory","limit",".","The","parameters","for","the","Nanny","are","mostly","the","same","as","those","for","the","Worker","with","exceptions","listed","below",".","Parameters","--","--","--","--","--","env",":","dict",",","optional","Environment","variables","set","at","time","of","Nanny","initialization","will","be","ensured","to","be","set","in","the","Worker","process","as","well",".","This","argument","allows","to","overwrite","or","otherwise","set","environment","variables","for","the","Worker",".","It","is","also","possible","to","set","environment","variables","using","the","option","``","distributed.nanny.environ","``",".","Precedence","as","follows","1",".","Nanny","arguments","2",".","Existing","environment","variables","3",".","Dask","configuration","..","note",":",":","Some","environment","variables",",","like","``","OMP_NUM_THREADS","``",",","must","be","set","before","importing","numpy","to","have","effect",".","Others",",","like","``","MALLOC_TRIM_THRESHOLD_","``","(","see",":","ref",":","`","memtrim","`",")",",","must","be","set","before","starting","the","Linux","process",".","Such","variables","would","be","ineffective","if","set","here","or","in","``","distributed.nanny.environ","``",";","they","must","be","set","in","``","distributed.nanny.pre-spawn-environ","``","so","that","they","are","set","before","spawning","the","subprocess",",","even","if","this","means","poisoning","the","process","running","the","Nanny",".","For","the","same","reason",",","be","warned","that","changing","``","distributed.worker.multiprocessing-method","``","from","``","spawn","``","to","``","fork","``","or","``","forkserver","``","may","inhibit","some","environment","variables",";","if","you","do",",","you","should","set","the","variables","yourself","in","the","shell","before","you","start","``","dask-worker","``",".","See","Also","--","--","--","--","Worker"]
code: def _close(self, *args, **kwargs):
      warnings.warn(
          "Worker._close has moved to Worker.close", stacklevel=2
      )
      return self.close(*args, **kwargs)
  
imports: from __future__ import annotations
  import asyncio
  import contextlib
  import errno
  import functools
  import logging
  import multiprocessing
  import os
  import shutil
  import threading
  import uuid
  import warnings
  import weakref
  from collections.abc import Callable, Collection
  from inspect import isawaitable
  from queue import Empty
  from typing import ClassVar, Literal, cast
  from toolz import merge
  from tornado.ioloop import IOLoop
  import dask
  from dask.system import CPU_COUNT
  from dask.utils import parse_timedelta
  from distributed import preloading
  from distributed.comm import get_address_host
  from distributed.comm.addressing import address_from_user_args
  from distributed.compatibility import asyncio_run
  from distributed.config import get_loop_factory
  from distributed.core import AsyncTaskGroupClosedError, CommClosedError, ErrorMessage, OKMessage, RPCClosed, Status, coerce_to_address, error_message
  from distributed.diagnostics.plugin import NannyPlugin, _get_plugin_name
  from distributed.metrics import time
  from distributed.node import ServerNode
  from distributed.process import AsyncProcess
  from distributed.proctitle import enable_proctitle_on_children
  from distributed.protocol import pickle
  from distributed.protocol.serialize import _is_dumpable
  from distributed.security import Security
  from distributed.utils import get_ip, get_mp_context, json_load_robust, log_errors, parse_ports, silence_logging_cmgr, wait_for
  from distributed.worker import Worker, run
  from distributed.worker_memory import DeprecatedMemoryManagerAttribute, DeprecatedMemoryMonitor, NannyMemoryManager
label_desc: Use image node_id 9 for calling the Nanny obj's underlying member method code with example usage: obj._close() and returns: self