code: def handle_lock(handle):
      
      
      def wrapper(self, *args, **options):
          def on_interrupt(signum, frame):
              # It's necessary to release lockfile
              sys.exit()
          signal.signal(signal.SIGTERM, on_interrupt)
  
          start_time = time.time()
          try:
              verbosity = int(options.get('verbosity', 0))
          except ValueError:
              verbosity = 0
          logger = logging.getLogger(self.__module__)
          if verbosity == 0:
              logger.level = logging.WARNING
          elif verbosity == 1:
              logger.level = logging.INFO
          else:
              logger.level = logging.DEBUG
         
          logger.debug("-" * 72)
          
          lock_name = self.__module__.split('.').pop()
          lock = FileLock(os.path.join(LOCK_ROOT, lock_name))
          
          logger.debug("%s - acquiring lock..." % lock_name)
          try:
              lock.acquire(LOCK_WAIT_TIMEOUT)
          except AlreadyLocked:
              logger.debug("lock already in place. quitting.")
              return
          except LockTimeout:
              logger.debug("waiting for the lock timed out. quitting.")
              return
          logger.debug("acquired.")
          
          try:
              handle(self, logger, *args, **options)
          except (KeyboardInterrupt, SystemExit):
              pass
          except:
              import traceback
              logging.warn("Command Failed")
              logging.warn('=' * 72)
              logging.warn(traceback.format_exc())
              logging.warn('=' * 72)
          
          logger.debug("releasing lock...")
          lock.release()
          logger.debug("released.")
          
          logger.info("done in %.2f seconds" % (time.time() - start_time))
          return
          
      return wrapper
docs: Decorate the handle method with a file lock to ensure there is only ever
      one process running at any one time.