class_docstr: Class for DVC repo lock.
  
  Args:
      lockfile (str): the lock filename
          in.
      tmp_dir (str): a directory to store claim files.
class_docstr_tok: ["Class","for","DVC","repo","lock",".","Args",":","lockfile","(","str",")",":","the","lock","filename","in",".","tmp_dir","(","str",")",":","a","directory","to","store","claim","files","."]
code: def __init__(self, lockfile, tmp_dir=None, **kwargs):
      import socket
  
      self._tmp_dir = tmp_dir
      super().__init__(lockfile)
  
      # NOTE: this is basically Lock.__init__ copy-paste, except that
      # instead of using `socket.getfqdn()` we use `socket.gethostname()`
      # to speed this up. We've seen [1] `getfqdn()` take ~5sec to return
      # anything, which is way too slow. `gethostname()` is actually a
      # fallback for `getfqdn()` when it is not able to resolve a
      # canonical hostname through network. The claimfile that uses
      # `self._hostname` is still usable, as it uses `pid` and random
      # number to generate the resulting lock file name, which is unique
      # enough for our application.
      #
      # [1] https://github.com/iterative/dvc/issues/2582
      self._hostname = socket.gethostname()
  
      self._lifetime = timedelta(days=365)  # Lock for good by default
      self._separator = flufl.lock.SEP
      self._set_claimfile()
      self._owned = True
      self._retry_errnos = []
  
imports: import hashlib
  import os
  from abc import ABC, abstractmethod
  from datetime import timedelta
  import flufl.lock
  import zc.lockfile
  from funcy import retry
  from dvc.exceptions import DvcException
  from dvc.progress import Tqdm
  from dvc.utils import format_link
label_desc: Use image node_id 1 to create a new HardlinkLock object from inherited base classes: flufl.lock, LockBase with example: obj = HardlinkLock(lockfile, tmp_dir)