@synchronized(IO_LOCK)
def save_data(data, _id, path, do_pickle=True, silent=False):
 if (not silent):
  logging.debug('Saving data for %s in %s', _id, path)
 path = os.path.join(path, _id)
 try:
  _f = open(path, 'wb')
  if do_pickle:
   if cfg.use_pickle():
    pickler = pickle.Pickler(_f, 2)
   else:
    pickler = cPickle.Pickler(_f, 2)
   pickler.dump(data)
   _f.flush()
   _f.close()
   pickler.clear_memo()
   del pickler
  else:
   _f.write(data)
   _f.flush()
   _f.close()
 except:
  logging.error(T('Saving %s failed'), path)
  logging.info('Traceback: ', exc_info=True)

@ synchronized ( IO_LOCK ) def save_data ( data , _id , path , do_pickle = True , silent = False ) : if ( not silent ) : logging . debug ( 'Saving data for %s in %s' , _id , path ) path = os . path . join ( path , _id ) try : _f = open ( path , 'wb' ) if do_pickle : if cfg . use_pickle ( ) : pickler = pickle . Pickler ( _f , 2 ) else : pickler = cPickle . Pickler ( _f , 2 ) pickler . dump ( data ) _f . flush ( ) _f . close ( ) pickler . clear_memo ( ) del pickler else : _f . write ( data ) _f . flush ( ) _f . close ( ) except : logging . error ( T ( 'Saving %s failed' ) , path ) logging . info ( 'Traceback: ' , exc_info = True )
save data to a diskfile .