def dump_recon_cache(cache_dict, cache_file, logger, lock_timeout=2):
 try:
  with lock_file(cache_file, lock_timeout, unlink=False) as cf:
   cache_entry = {}
   try:
    existing_entry = cf.readline()
    if existing_entry:
     cache_entry = json.loads(existing_entry)
   except ValueError:
    pass
   for (cache_key, cache_value) in cache_dict.items():
    cache_entry[cache_key] = cache_value
   try:
    with NamedTemporaryFile(dir=os.path.dirname(cache_file), delete=False) as tf:
     tf.write((json.dumps(cache_entry) + '\n'))
    os.rename(tf.name, cache_file)
   finally:
    try:
     os.unlink(tf.name)
    except OSError as err:
     if (err.errno != errno.ENOENT):
      raise
 except (Exception, Timeout):
  logger.exception(_('Exception dumping recon cache'))

def dump_recon_cache ( cache_dict , cache_file , logger , lock_timeout = 2 ) : try : with lock_file ( cache_file , lock_timeout , unlink = False ) as cf : cache_entry = { } try : existing_entry = cf . readline ( ) if existing_entry : cache_entry = json . loads ( existing_entry ) except ValueError : pass for ( cache_key , cache_value ) in cache_dict . items ( ) : cache_entry [ cache_key ] = cache_value try : with NamedTemporaryFile ( dir = os . path . dirname ( cache_file ) , delete = False ) as tf : tf . write ( ( json . dumps ( cache_entry ) + '\n' ) ) os . rename ( tf . name , cache_file ) finally : try : os . unlink ( tf . name ) except OSError as err : if ( err . errno != errno . ENOENT ) : raise except ( Exception , Timeout ) : logger . exception ( _ ( 'Exception dumping recon cache' ) )
update recon cache values .