'Write the in-memory database index to its file path.
This is a helper function called by the WriteTransaction context
manager. If there is an exception while the write lock is active,
nothing will be written to the database file, but the in-memory
database *may* be left in an inconsistent state.  It will be consistent
after the start of the next transaction, when it read from disk again.
This routine does no locking.'

def _write(self, type, value, traceback):

    if (type is not None):
        return
    temp_file = (self._index_path + ('.%s.%s.temp' % (socket.getfqdn(), os.getpid())))
    try:
        with open(temp_file, 'w') as f:
            self._write_to_file(f)
        os.rename(temp_file, self._index_path)
    except:
        if os.path.exists(temp_file):
            os.remove(temp_file)
        raise
