code: def flush(self):
          
          if self.flag[0] != 'r':
              with self.write_mutex:
                  if hasattr(self.db, 'sync'):
                      self.db.sync()
                  else:
                      # fall-back, close and re-open, needed for ndbm
                      flag = self.flag
                      if flag[0] == 'n':
                          flag = 'c' + flag[1:]  # don't clobber an existing database
                      self.db.close()
                      # noinspection PyArgumentList
                      self.db = self.open(self.path, flag, self.mode, **self.open_kwargs)
docs: Synchronizes data to the underlying database file.