Repository navigation
Some tests leak temporary files #81602
Copy link
Copy link
Closed
Labels
Description
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee = None
closed_at = <Date 2019-07-08.22:10:28.983>
created_at = <Date 2019-06-26.22:34:15.944>
labels = ['tests', '3.9']
title = 'Some tests leak temporary files'
updated_at = <Date 2020-04-23.22:44:12.215>
user = 'https://github.com/vstinner'bugs.python.org fields:
activity = <Date 2020-04-23.22:44:12.215>
actor = 'vstinner'
assignee = 'none'
closed = True
closed_date = <Date 2019-07-08.22:10:28.983>
closer = 'vstinner'
components = ['Tests']
creation = <Date 2019-06-26.22:34:15.944>
creator = 'vstinner'
dependencies = []
files = []
hgrepos = []
issue_num = 37421
keywords = ['patch']
message_count = 26.0
messages = ['346692', '346693', '346699', '346700', '346703', '347127', '347135', '347137', '347140', '347191', '347192', '347193', '347199', '347201', '347204', '347265', '347270', '347273', '347343', '347348', '347352', '347355', '347492', '347493', '347513', '367157']
nosy_count = 5.0
nosy_names = ['vstinner', 'zach.ware', 'serhiy.storchaka', 'pablogsal', 'miss-islington']
pr_nums = ['14415', '14416', '14417', '14527', '14529', '14554', '14562', '14563', '14564', '14569', '14570', '14571', '14572', '14585', '14586', '14601', '14602', '14643', '14645', '17641']
priority = 'normal'
resolution = 'fixed'
stage = 'resolved'
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue37421'
versions = ['Python 3.9']Reactions are currently unavailable
Activity
vstinner commentedon Jun 26, 2019
When running tests, the tempoary directory is not left clean: there are temporary files which are not removed.
I wrote a PoC change to detect such bugs and I found that at least test_shutil and test_urllib leak such temporary files/directories.
vstinner commentedon Jun 26, 2019
Test leaking a temporary file in test_urllib:
test.test_urllib.urlretrieve_HttpTests.test_short_content_raises_ContentTooShortError_without_reporthook
I'm not sure of my fix:
vstinner commentedon Jun 26, 2019
Using PR 14415, the following test of test_multiprocessing_spawn emits a false alarm because multiprocessing use "Finalizer" objects which are only finalized "later":
test.test_multiprocessing_spawn.WithManagerTestMyManager.test_mymanager_context_prestarted
Workaround, call explicitly _run_finalizers():
[-]Tests leak temporary files[/-][+]Some tests leak temporary files[/+]vstinner commentedon Jun 26, 2019
New changeset 4c26abd by Victor Stinner in branch 'master':
bpo-37421: Fix test_shutil: don't leak temporary files (GH-14416)
4c26abd
miss-islington commentedon Jun 26, 2019
New changeset 7fe81ce by Miss Islington (bot) in branch '3.8':
bpo-37421: Fix test_shutil: don't leak temporary files (GH-14416)
7fe81ce
vstinner commentedon Jul 2, 2019
About urllib.request, I created: bpo-37475 "What is urllib.request.urlcleanup() function?".
vstinner commentedon Jul 2, 2019
New changeset 039fb49 by Victor Stinner in branch 'master':
bpo-37421: multiprocessing tests call _run_finalizers() (GH-14527)
039fb49
miss-islington commentedon Jul 2, 2019
New changeset 632cb36 by Miss Islington (bot) in branch '3.8':
bpo-37421: multiprocessing tests call _run_finalizers() (GH-14527)
632cb36
vstinner commentedon Jul 2, 2019
New changeset 7cb9204 by Victor Stinner in branch 'master':
bpo-37421: urllib.request tests call urlcleanup() (GH-14529)
7cb9204
vstinner commentedon Jul 3, 2019
New changeset b71d8d6 by Victor Stinner in branch 'master':
bpo-37421: test_winconsoleio doesn't leak temp file anymore (GH-14562)
b71d8d6
vstinner commentedon Jul 3, 2019
New changeset 684cb47 by Victor Stinner in branch 'master':
bpo-37421: test_concurrent_futures cleans up multiprocessing (GH-14563)
684cb47
vstinner commentedon Jul 3, 2019
New changeset 74c9dd5 by Victor Stinner in branch 'master':
bpo-37421: Fix test_distutils.test_build_ext() (GH-14564)
74c9dd5
1 remaining item
miss-islington commentedon Jul 3, 2019
New changeset 79665c6 by Miss Islington (bot) in branch '3.8':
bpo-37421: test_concurrent_futures cleans up multiprocessing (GH-14563)
79665c6
miss-islington commentedon Jul 3, 2019
New changeset 0aefba7 by Miss Islington (bot) in branch '3.8':
bpo-37421: Fix test_distutils.test_build_ext() (GH-14564)
0aefba7
vstinner commentedon Jul 4, 2019
New changeset 9d40554 by Victor Stinner in branch 'master':
bpo-37421: Fix multiprocessing get_temp_dir() finalizer (GH-14572)
9d40554
miss-islington commentedon Jul 4, 2019
New changeset 2d438fc by Miss Islington (bot) in branch '3.7':
bpo-37421: Fix multiprocessing get_temp_dir() finalizer (GH-14572)
2d438fc
miss-islington commentedon Jul 4, 2019
New changeset 957656e by Miss Islington (bot) in branch '3.8':
bpo-37421: Fix multiprocessing get_temp_dir() finalizer (GH-14572)
957656e
vstinner commentedon Jul 5, 2019
./python -u -m test test_multiprocessing_spawn -R 3:3 still fail:
ERROR: test_context (test.test_multiprocessing_spawn.TestStartMethod)
ERROR: test_set_get (test.test_multiprocessing_spawn.TestStartMethod)
PR 14601 fix these tests when test_multiprocessing_spawn is run more than once.
vstinner commentedon Jul 5, 2019
New changeset 8fbeb14 by Victor Stinner in branch 'master':
bpo-37421: multiprocessing tests now stop ForkServer (GH-14601)
8fbeb14
vstinner commentedon Jul 5, 2019
I created a follow-up issue: bpo-37507 "multiprocessing: Add a stop() method to ForkServer".
miss-islington commentedon Jul 5, 2019
New changeset 229f6e8 by Miss Islington (bot) in branch '3.8':
bpo-37421: multiprocessing tests now stop ForkServer (GH-14601)
229f6e8
vstinner commentedon Jul 8, 2019
New changeset e676244 by Victor Stinner in branch 'master':
bpo-37421: test_concurrent_futures stops ForkServer (GH-14643)
e676244
vstinner commentedon Jul 8, 2019
New changeset cdada40 by Victor Stinner (Miss Islington (bot)) in branch '3.8':
bpo-37421: test_concurrent_futures stops ForkServer (GH-14643) (GH-14645)
cdada40
vstinner commentedon Jul 8, 2019
It seems like tests don't leak temporary files anymore:
I close the issue.
vstinner commentedon Apr 23, 2020
New changeset fd32a0e by Victor Stinner in branch '3.7':
[3.7] bpo-38546: Backport multiprocessing tests fixes from master (GH-19689)
fd32a0e