def patch_flush_fsync(db_obj):
 def always_fsync(ind_obj):
  def _inner():
   ind_obj.orig_flush()
   ind_obj.fsync()
  return _inner
 for index in db_obj.indexes:
  setattr(index, 'orig_flush', index.flush)
  setattr(index, 'flush', always_fsync(index))
 setattr(db_obj, 'orig_flush', db_obj.flush)
 setattr(db_obj, 'flush', always_fsync(db_obj))
 return

def patch_flush_fsync ( db_obj ) : def always_fsync ( ind_obj ) : def _inner ( ) : ind_obj . orig_flush ( ) ind_obj . fsync ( ) return _inner for index in db_obj . indexes : setattr ( index , 'orig_flush' , index . flush ) setattr ( index , 'flush' , always_fsync ( index ) ) setattr ( db_obj , 'orig_flush' , db_obj . flush ) setattr ( db_obj , 'flush' , always_fsync ( db_obj ) ) return
will always execute index .