gh-102251: add missing cleanups for `test_import` by sunmy2019 · Pull Request #104796 · python/cpython
Oh, seems your solution also works on Windows. ( I forgot to add -j 1 parameter 🤦♂️ , sorry)
But problem with test_concurrency still there, and that's interesting, because it doesn't reproducible on Linux.
Probably, it should be a another PR (at the current moment I still haven't found a solution).
My some notes about it:
If we delete these lines from test_concurrency:
sys.modules.pop('package', None) sys.modules.pop('package.submodule', None)
Refleak tests will pass.
Also, this problem confirms that Windows runner in buildbots fleet really needed.