This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients brett.cannon, ezio.melotti, michael.foord, serhiy.storchaka
Date 2019-03-30.11:56:59
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1553947019.94.0.789476600198.issue36485@roundup.psfhosted.org>
In-reply-to
Content
Some modules have caches. There is a need to clear all tests before running tests. Brett proposed to add in all modules with caches a function with the standardized name which is responsible for clearing module related caches. [1]

The proposed PR adds a new function clear_caches() in the sys module. It iterates all imported modules and calls function __clearcache__() if it is defined.

    def clear_caches():
        for mod in reversed(list(sys.modules.values())):
            if hasattr(mod, '__clearcache__'):
                mod.__clearcache__()

clear_caches() will be used in test.regrtest and can be used in user code. The PR defines also function __clearcache__ for modules which are cleared manually in the current code.

This is a preliminary implementation, bikeshedding is welcome.

[1] https://mail.python.org/pipermail/python-ideas/2019-March/056165.html
History
Date User Action Args
2019-03-30 11:56:59serhiy.storchakasetrecipients: + serhiy.storchaka, brett.cannon, ezio.melotti, michael.foord
2019-03-30 11:56:59serhiy.storchakasetmessageid: <1553947019.94.0.789476600198.issue36485@roundup.psfhosted.org>
2019-03-30 11:56:59serhiy.storchakalinkissue36485 messages
2019-03-30 11:56:59serhiy.storchakacreate