theano/gof/cmodule.py
def clear_unversioned(self, min_age=None):
        """Delete unversioned dynamic modules.

        They are deleted both from the internal dictionaries and from the
        filesystem.

        No need to have the lock when calling this method. It does not
        take the lock as unversioned module aren't shared.

        This method does not refresh the cache content, it just
        accesses the in-memory known module(s).

        Parameters
        ----------
        min_age
            Minimum age to be deleted, in seconds. Defaults to
            7-day age if not provided.

        """
        if min_age is None:
            min_age = self.age_thresh_del_unversioned

        # As this delete object that we build and other don't use, we
        # don't need the lock.
        all_key_datas = list(self.module_hash_to_key_data.values())
        for key_data in all_key_datas:
            if not key_data.keys:
                # May happen for broken versioned keys.
                continue
            for key_idx, key in enumerate(key_data.keys):
                version, rest = key
                if version:
                    # Since the version is included in the module hash,
                    # it should not be possible to mix versioned and
                    # unversioned keys in the same KeyData object.
                    assert key_idx == 0
                    break
            if not version:
                # Note that unversioned keys cannot be broken, so we can
                # set do_manual_check to False to speed things up.
                key_data.delete_keys_from(self.entry_from_key,
                                          do_manual_check=False)
                entry = key_data.get_entry()
                # Entry is guaranteed to be in this dictionary, because
                # an unversioned entry should never have been loaded via
                # refresh.
                assert entry in self.module_from_name

                del self.module_from_name[entry]
                del self.module_hash_to_key_data[key_data.module_hash]

                parent = os.path.dirname(entry)
                assert parent.startswith(os.path.join(self.dirname, 'tmp'))
                _rmtree(parent, msg='unversioned', level=logging.INFO,
                        ignore_nocleanup=True)

        # Sanity check: all unversioned keys should have been removed at
        # this point.
        for key in self.entry_from_key:
            assert key[0]

        to_del = []
        time_now = time.time()
        for filename in os.listdir(self.dirname):
            if filename.startswith('tmp'):
                try:
                    fname = os.path.join(self.dirname, filename, 'key.pkl')
                    open(fname).close()
                    has_key = True
                except IOError:
                    has_key = False
                if not has_key:
                    # Use the compiled file by default
                    path = module_name_from_dir(os.path.join(self.dirname,
                                                             filename),
                                                False)
                    # If it don't exist, use any file in the directory.
                    if path is None:
                        path = os.path.join(self.dirname, filename)
                        try:
                            files = os.listdir(path)
                        except OSError as e:
                            if e.errno == 2:  # No such file or directory
                                # if it don't exist anymore, it mean
                                # the clean up was already done by
                                # someone else, so nothing to do about
                                # it.
                                continue
                        if files:
                            path = os.path.join(path, files[0])
                        else:
                            # If the directory is empty skip it.
                            # They are deleted elsewhere.
                            continue
                    age = time_now - last_access_time(path)

                    # In normal case, the processus that created this
                    # directory will delete it. However, if this processus
                    # crashes, it will not be cleaned up.
                    # As we don't know if this directory is still used,
                    # we wait one week and suppose that the processus
                    # crashed, and we take care of the clean-up.
                    if age > min_age:
                        to_del.append(os.path.join(self.dirname, filename))

        # No need to take the lock as it isn't shared.
        for f in to_del:
            _rmtree(f,
                    msg='old unversioned', level=logging.INFO,
                    ignore_nocleanup=True)
Delete unversioned dynamic modules.

        They are deleted both from the internal dictionaries and from the
        filesystem.

        No need to have the lock when calling this method. It does not
        take the lock as unversioned module aren't shared.

        This method does not refresh the cache content, it just
        accesses the in-memory known module(s).

        Parameters
        ----------
        min_age
            Minimum age to be deleted, in seconds. Defaults to
            7-day age if not provided.

        
Delete unversioned dynamic modules.
They are deleted both from the internal dictionaries and from the
filesystem.

No need to have the lock when calling this method. It does not
take the lock as unversioned module aren't shared.

This method does not refresh the cache content, it just
accesses the in-memory known module(s).

Parameters

min_age
Minimum age to be deleted, in seconds. Defaults to
7-day age if not provided.
Delete unversioned dynamic modules . They are deleted both from the internal dictionaries and from the filesystem . No need to have the lock when calling this method . It does not take the lock as unversioned module aren ' t shared . This method does not refresh the cache content it just accesses the in - memory known module ( s ) . Parameters min_age Minimum age to be deleted in seconds . Defaults to 7 - day age if not provided .
def clear_unversioned(self, min_age=None):
        if min_age is None:
            min_age = self.age_thresh_del_unversioned
        all_key_datas = list(self.module_hash_to_key_data.values())
        for key_data in all_key_datas:
            if not key_data.keys:
                continue
            for key_idx, key in enumerate(key_data.keys):
                version, rest = key
                if version:
                    assert key_idx == 0
                    break
            if not version:
                key_data.delete_keys_from(self.entry_from_key,
                                          do_manual_check=False)
                entry = key_data.get_entry()
                assert entry in self.module_from_name
                del self.module_from_name[entry]
                del self.module_hash_to_key_data[key_data.module_hash]
                parent = os.path.dirname(entry)
                assert parent.startswith(os.path.join(self.dirname, 'tmp'))
                _rmtree(parent, msg='unversioned', level=logging.INFO,
                        ignore_nocleanup=True)
        for key in self.entry_from_key:
            assert key[0]
        to_del = []
        time_now = time.time()
        for filename in os.listdir(self.dirname):
            if filename.startswith('tmp'):
                try:
                    fname = os.path.join(self.dirname, filename, 'key.pkl')
                    open(fname).close()
                    has_key = True
                except IOError:
                    has_key = False
                if not has_key:
                    path = module_name_from_dir(os.path.join(self.dirname,
                                                             filename),
                                                False)
                    if path is None:
                        path = os.path.join(self.dirname, filename)
                        try:
                            files = os.listdir(path)
                        except OSError as e:
                            if e.errno == 2:  
                                continue
                        if files:
                            path = os.path.join(path, files[0])
                        else:
                            continue
                    age = time_now - last_access_time(path)
                    if age > min_age:
                        to_del.append(os.path.join(self.dirname, filename))
        for f in to_del:
            _rmtree(f,
                    msg='old unversioned', level=logging.INFO,
                    ignore_nocleanup=True)
def clear_unversioned ( self , min_age = None ) : if min_age is None : min_age = self . age_thresh_del_unversioned all_key_datas = list ( self . module_hash_to_key_data . values ( ) ) for key_data in all_key_datas : if not key_data . keys : continue for key_idx , key in enumerate ( key_data . keys ) : version , rest = key if version : assert key_idx == 0 break if not version : key_data . delete_keys_from ( self . entry_from_key , do_manual_check = False ) entry = key_data . get_entry ( ) assert entry in self . module_from_name del self . module_from_name [ entry ] del self . module_hash_to_key_data [ key_data . module_hash ] parent = os . path . dirname ( entry ) assert parent . startswith ( os . path . join ( self . dirname , 'tmp' ) ) _rmtree ( parent , msg = 'unversioned' , level = logging . INFO , ignore_nocleanup = True ) for key in self . entry_from_key : assert key [ 0 ] to_del = [ ] time_now = time . time ( ) for filename in os . listdir ( self . dirname ) : if filename . startswith ( 'tmp' ) : try : fname = os . path . join ( self . dirname , filename , 'key.pkl' ) open ( fname ) . close ( ) has_key = True except IOError : has_key = False if not has_key : path = module_name_from_dir ( os . path . join ( self . dirname , filename ) , False ) if path is None : path = os . path . join ( self . dirname , filename ) try : files = os . listdir ( path ) except OSError as e : if e . errno == 2 : continue if files : path = os . path . join ( path , files [ 0 ] ) else : continue age = time_now - last_access_time ( path ) if age > min_age : to_del . append ( os . path . join ( self . dirname , filename ) ) for f in to_del : _rmtree ( f , msg = 'old unversioned' , level = logging . INFO , ignore_nocleanup = True )
Delete unversioned dynamic modules.
Delete unversioned dynamic modules .
"""Delete unversioned dynamic modules.

        They are deleted both from the internal dictionaries and from the
        filesystem.

        No need to have the lock when calling this method. It does not
        take the lock as unversioned module aren't shared.

        This method does not refresh the cache content, it just
        accesses the in-memory known module(s).

        Parameters
        ----------
        min_age
            Minimum age to be deleted, in seconds. Defaults to
            7-day age if not provided.

        """ # As this delete object that we build and other don't use, we # don't need the lock. # May happen for broken versioned keys. # Since the version is included in the module hash, # it should not be possible to mix versioned and # unversioned keys in the same KeyData object. # Note that unversioned keys cannot be broken, so we can # set do_manual_check to False to speed things up. # Entry is guaranteed to be in this dictionary, because # an unversioned entry should never have been loaded via # refresh. # Sanity check: all unversioned keys should have been removed at # this point. # Use the compiled file by default # If it don't exist, use any file in the directory. # No such file or directory # if it don't exist anymore, it mean # the clean up was already done by # someone else, so nothing to do about # it. # If the directory is empty skip it. # They are deleted elsewhere. # In normal case, the processus that created this # directory will delete it. However, if this processus # crashes, it will not be cleaned up. # As we don't know if this directory is still used, # we wait one week and suppose that the processus # crashed, and we take care of the clean-up. # No need to take the lock as it isn't shared.
self
min_age