def write_pickle(obj, dest, tmp=None, pickle_protocol=0):
 if (tmp is None):
  tmp = os.path.dirname(dest)
 (fd, tmppath) = mkstemp(dir=tmp, suffix='.tmp')
 with os.fdopen(fd, 'wb') as fo:
  pickle.dump(obj, fo, pickle_protocol)
  fo.flush()
  os.fsync(fd)
  renamer(tmppath, dest)

def write_pickle ( obj , dest , tmp = None , pickle_protocol = 0 ) : if ( tmp is None ) : tmp = os . path . dirname ( dest ) ( fd , tmppath ) = mkstemp ( dir = tmp , suffix = '.tmp' ) with os . fdopen ( fd , 'wb' ) as fo : pickle . dump ( obj , fo , pickle_protocol ) fo . flush ( ) os . fsync ( fd ) renamer ( tmppath , dest )
ensure that a pickle file gets written to disk .