mirror of
				https://github.com/django/django.git
				synced 2025-10-31 09:41:08 +00:00 
			
		
		
		
	Changed strategy for removing TMPDIR in runtests.py.
Previously, a traceback would be displayed on exit because: - using some multiprocessing features creates a temporary directory - this directory would be inside TMPDIR - multiprocessing would attempt to remove it when a particular object was deallocated, after runtests.py had already removed it along with everything else in TMPDIR.
This commit is contained in:
		| @@ -1,4 +1,5 @@ | ||||
| #!/usr/bin/env python | ||||
| import atexit | ||||
| import logging | ||||
| import os | ||||
| import shutil | ||||
| @@ -35,6 +36,12 @@ TMPDIR = tempfile.mkdtemp(prefix='django_') | ||||
| # so that children processes inherit it. | ||||
| tempfile.tempdir = os.environ['TMPDIR'] = TMPDIR | ||||
|  | ||||
| # Removing the temporary TMPDIR. Ensure we pass in unicode so that it will | ||||
| # successfully remove temp trees containing non-ASCII filenames on Windows. | ||||
| # (We're assuming the temp dir name itself only contains ASCII characters.) | ||||
| atexit.register(shutil.rmtree, six.text_type(TMPDIR)) | ||||
|  | ||||
|  | ||||
| SUBDIRS_TO_SKIP = [ | ||||
|     'data', | ||||
|     'import_error_package', | ||||
| @@ -220,15 +227,6 @@ def setup(verbosity, test_labels, parallel): | ||||
|  | ||||
|  | ||||
| def teardown(state): | ||||
|     try: | ||||
|         # Removing the temporary TMPDIR. Ensure we pass in unicode | ||||
|         # so that it will successfully remove temp trees containing | ||||
|         # non-ASCII filenames on Windows. (We're assuming the temp dir | ||||
|         # name itself does not contain non-ASCII characters.) | ||||
|         shutil.rmtree(six.text_type(TMPDIR)) | ||||
|     except OSError: | ||||
|         print('Failed to remove temp directory: %s' % TMPDIR) | ||||
|  | ||||
|     # Restore the old settings. | ||||
|     for key, value in state.items(): | ||||
|         setattr(settings, key, value) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user