pypet/storageservice.py
def _srvc_closing_routine(self, closing):
        """Routine to close an hdf5 file

        The file is closed only when `closing=True`. `closing=True` means that
        the file was opened in the current highest recursion level. This prevents re-opening
        and closing of the file if `store` or `load` are called recursively.

        """
        if (not self._keep_open and
                closing and
                    self.is_open):

            f_fd = self._hdf5file.fileno()
            self._hdf5file.flush()
            try:
                os.fsync(f_fd)
                try:
                    self._hdf5store.flush(fsync=True)
                except TypeError:
                    f_fd = self._hdf5store._handle.fileno()
                    self._hdf5store.flush()
                    os.fsync(f_fd)
            except OSError as exc:
                # This seems to be the only way to avoid an OSError under Windows
                errmsg = ('Encountered OSError while flushing file.'
                                   'If you are using Windows, don`t worry! '
                                   'I will ignore the error and try to close the file. '
                                   'Original error: %s' % repr(exc))
                self._logger.debug(errmsg)

            self._hdf5store.close()
            if self._hdf5file.isopen:
                self._logger.error('Could not close HDF5 file!')
            self._hdf5file = None
            self._hdf5store = None
            self._trajectory_group = None
            self._trajectory_name = None
            self._trajectory_index = None
            self._overview_group_ = None
            self._logger.debug('Closing HDF5 file')
            return True
        else:
            return False
def _srvc_closing_routine(self, closing):
        if (not self._keep_open and
                closing and
                    self.is_open):

            f_fd = self._hdf5file.fileno()
            self._hdf5file.flush()
            try:
                os.fsync(f_fd)
                try:
                    self._hdf5store.flush(fsync=True)
                except TypeError:
                    f_fd = self._hdf5store._handle.fileno()
                    self._hdf5store.flush()
                    os.fsync(f_fd)
            except OSError as exc:
                # This seems to be the only way to avoid an OSError under Windows
                errmsg = ('Encountered OSError while flushing file.'
                                   'If you are using Windows, don`t worry! '
                                   'I will ignore the error and try to close the file. '
                                   'Original error: %s' % repr(exc))
                self._logger.debug(errmsg)

            self._hdf5store.close()
            if self._hdf5file.isopen:
                self._logger.error('Could not close HDF5 file!')
            self._hdf5file = None
            self._hdf5store = None
            self._trajectory_group = None
            self._trajectory_name = None
            self._trajectory_index = None
            self._overview_group_ = None
            self._logger.debug('Closing HDF5 file')
            return True
        else:
            return False
def _srvc_closing_routine ( self , closing ) : if ( not self . _keep_open and closing and self . is_open ) : f_fd = self . _hdf5file . fileno ( ) self . _hdf5file . flush ( ) try : os . fsync ( f_fd ) try : self . _hdf5store . flush ( fsync = True ) except TypeError : f_fd = self . _hdf5store . _handle . fileno ( ) self . _hdf5store . flush ( ) os . fsync ( f_fd ) except OSError as exc : # This seems to be the only way to avoid an OSError under Windows errmsg = ( 'Encountered OSError while flushing file.' 'If you are using Windows, don`t worry! ' 'I will ignore the error and try to close the file. ' 'Original error: %s' % repr ( exc ) ) self . _logger . debug ( errmsg ) self . _hdf5store . close ( ) if self . _hdf5file . isopen : self . _logger . error ( 'Could not close HDF5 file!' ) self . _hdf5file = None self . _hdf5store = None self . _trajectory_group = None self . _trajectory_name = None self . _trajectory_index = None self . _overview_group_ = None self . _logger . debug ( 'Closing HDF5 file' ) return True else : return False
Routine to close an hdf5 file

        The file is closed only when `closing=True`. `closing=True` means that
        the file was opened in the current highest recursion level. This prevents re-opening
        and closing of the file if `store` or `load` are called recursively.
Routine to close an hdf5 file