def _acquire_download_cache_lock():
 lockdir = os.path.join(_get_download_cache_locs()[0], u'lock')
 for i in range(conf.download_cache_lock_attempts):
  try:
   os.mkdir(lockdir)
   with open(os.path.join(lockdir, u'pid'), u'w') as f:
    f.write(str(os.getpid()))
  except OSError:
   time.sleep(1)
  else:
   return
 msg = u"Unable to acquire lock for cache directory ({0} exists). You may need to delete the lock if the python interpreter wasn't shut down properly."
 raise RuntimeError(msg.format(lockdir))

def _acquire_download_cache_lock ( ) : lockdir = os . path . join ( _get_download_cache_locs ( ) [ 0 ] , u'lock' ) for i in range ( conf . download_cache_lock_attempts ) : try : os . mkdir ( lockdir ) with open ( os . path . join ( lockdir , u'pid' ) , u'w' ) as f : f . write ( str ( os . getpid ( ) ) ) except OSError : time . sleep ( 1 ) else : return msg = u"Unable to acquire lock for cache directory ({0} exists). You may need to delete the lock if the python interpreter wasn't shut down properly." raise RuntimeError ( msg . format ( lockdir ) )
uses the lock directory method .