class_docstr: Class wrapper around release mechanism so that the lock is automatically
  released when the program exits (even when crashing or being interrupted),
  using the __del__ class method.
class_docstr_tok: ["Class","wrapper","around","release","mechanism","so","that","the","lock","is","automatically","released","when","the","program","exits","(","even","when","crashing","or","being","interrupted",")",",","using","the","__del__","class","method","."]
docstr: Remove current lock.
  
  This function does not crash if it is unable to properly
  delete the lock file and directory. The reason is that it
  should be allowed for multiple jobs running in parallel to
  unlock the same directory at the same time (e.g. when reaching
  their timeout limit).
docstr_tok: ["Remove","current","lock",".","This","function","does","not","crash","if","it","is","unable","to","properly","delete","the","lock","file","and","directory",".","The","reason","is","that","it","should","be","allowed","for","multiple","jobs","running","in","parallel","to","unlock","the","same","directory","at","the","same","time","(","e.g",".","when","reaching","their","timeout","limit",")","."]
code: def unlock(self, force=False):
      """
      Remove current lock.
  
      This function does not crash if it is unable to properly
      delete the lock file and directory. The reason is that it
      should be allowed for multiple jobs running in parallel to
      unlock the same directory at the same time (e.g. when reaching
      their timeout limit).
  
      """
      # If any error occurs, we assume this is because someone else tried to
      # unlock this directory at the same time.
      # Note that it is important not to have both remove statements within
      # the same try/except block. The reason is that while the attempt to
      # remove the file may fail (e.g. because for some reason this file does
      # not exist), we still want to try and remove the directory.
  
      # Check if someone else didn't took our lock.
      lock_file = os.path.join(self.tmp_dir, "lock")
      if not force:
          try:
              with open(lock_file) as f:
                  owner = f.readlines()[0].strip()
                  pid, _, hname = owner.split("_")
                  if pid != str(os.getpid()) or hname != hostname:
                      return
          except Exception:
              pass
  
      try:
          os.remove(lock_file)
      except Exception:
          pass
      try:
          os.rmdir(self.tmp_dir)
      except Exception:
          pass
  
imports: from __future__ import absolute_import, print_function, division
  import atexit
  import os
  import socket
  import time
  import logging
  from six import PY3
  from contextlib import contextmanager
  import numpy
  from theano import config
label_desc: Use image node_id 2 for calling the Unlocker obj's underlying member method code with example usage: obj.unlock(force) without return types