class_docstr: An on-disk workspace that tracks disposable work directories inside it.
  If a process crashes or another event left stale directories behind,
  this will be detected and the directories purged.
class_docstr_tok: ["An","on-disk","workspace","that","tracks","disposable","work","directories","inside","it",".","If","a","process","crashes","or","another","event","left","stale","directories","behind",",","this","will","be","detected","and","the","directories","purged","."]
docstr: Create and return a new WorkDir in this WorkSpace.
  Either the *prefix* or *name* parameter should be given
  (*prefix* is preferred as it avoids potential collisions)
  
  Parameters
  ----------
  prefix : str (optional)
      The prefix of the temporary subdirectory name for the workdir
  name : str (optional)
      The subdirectory name for the workdir
docstr_tok: ["Create","and","return","a","new","WorkDir","in","this","WorkSpace",".","Either","the","*","prefix","*","or","*","name","*","parameter","should","be","given","(","*","prefix","*","is","preferred","as","it","avoids","potential","collisions",")","Parameters","--","--","--","--","--","prefix",":","str","(","optional",")","The","prefix","of","the","temporary","subdirectory","name","for","the","workdir","name",":","str","(","optional",")","The","subdirectory","name","for","the","workdir"]
code: def new_work_dir(self, **kwargs):
      """
      Create and return a new WorkDir in this WorkSpace.
      Either the *prefix* or *name* parameter should be given
      (*prefix* is preferred as it avoids potential collisions)
  
      Parameters
      ----------
      prefix : str (optional)
          The prefix of the temporary subdirectory name for the workdir
      name : str (optional)
          The subdirectory name for the workdir
      """
      try:
          self._purge_leftovers()
      except OSError:
          logger.error(
              "Failed to clean up lingering worker directories in path: %s ",
              exc_info=True,
          )
      return WorkDir(self, **kwargs)
  
imports: from __future__ import annotations
  import glob
  import logging
  import os
  import shutil
  import stat
  import sys
  import tempfile
  import weakref
  from typing import ClassVar
  import locket
  import dask
label_desc: Use image node_id 9 for calling the WorkSpace obj's underlying member method code with example usage: obj.new_work_dir() and returns: WorkDir