class_docstr: An extension for the scheduler to manage Semaphores
  
  This adds the following routes to the scheduler
  
  * semaphore_acquire
  * semaphore_release
  * semaphore_close
  * semaphore_refresh_leases
  * semaphore_register
class_docstr_tok: ["An","extension","for","the","scheduler","to","manage","Semaphores","This","adds","the","following","routes","to","the","scheduler","*","semaphore_acquire","*","semaphore_release","*","semaphore_close","*","semaphore_refresh_leases","*","semaphore_register"]
docstr: Hard close the semaphore without warning clients which still hold a lease.
code: def close(self, name=None):
      """Hard close the semaphore without warning clients which still hold a lease."""
      if not self._semaphore_exists(name):
          return
  
      del self.max_leases[name]
      if name in self.events:
          del self.events[name]
      if name in self.leases:
          if self.leases[name]:
              warnings.warn(
                  f"Closing semaphore {name} but there remain unreleased leases {sorted(self.leases[name])}",
                  RuntimeWarning,
              )
          del self.leases[name]
      if name in self.metrics["pending"]:
          if self.metrics["pending"][name]:
              warnings.warn(
                  f"Closing semaphore {name} but there remain pending leases",
                  RuntimeWarning,
              )
      # Clean-up state of semaphore metrics
      for _, metric_dict in self.metrics.items():
          if name in metric_dict:
              del metric_dict[name]
  
imports: from __future__ import annotations
  import asyncio
  import logging
  import uuid
  import warnings
  from asyncio import TimeoutError
  from collections import defaultdict, deque
  import dask
  from dask.utils import parse_timedelta
  from distributed.compatibility import PeriodicCallback
  from distributed.metrics import time
  from distributed.utils import Deadline, SyncMethodMixin, log_errors, wait_for
  from distributed.utils_comm import retry_operation
  from distributed.worker import get_client, get_worker
label_desc: Use image node_id 10 for calling the SemaphoreExtension obj's underlying member method code with example usage: obj.close(name) without return types