Message339190
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 |
|
Date |
User |
Action |
Args |
2019-03-30 11:56:59 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, brett.cannon, ezio.melotti, michael.foord |
2019-03-30 11:56:59 | serhiy.storchaka | set | messageid: <1553947019.94.0.789476600198.issue36485@roundup.psfhosted.org> |
2019-03-30 11:56:59 | serhiy.storchaka | link | issue36485 messages |
2019-03-30 11:56:59 | serhiy.storchaka | create | |
|