cpython: c2a13acd5e2b (original) (raw)

Mercurial > cpython

changeset 87070:c2a13acd5e2b

Close #19466: Clear the frames of daemon threads earlier during the Python shutdown to call objects destructors. So "unclosed file" resource warnings are now corretly emitted for daemon threads. [#19466]

Victor Stinner victor.stinner@gmail.com
date Tue, 12 Nov 2013 16:37:55 +0100
parents cb05beabb656
children 10a8e676b87b
files Lib/test/test_threading.py Misc/NEWS Python/pythonrun.c
diffstat 3 files changed, 69 insertions(+), 5 deletions(-)[+] [-] Lib/test/test_threading.py 50 Misc/NEWS 4 Python/pythonrun.c 20

line wrap: on

line diff

--- a/Lib/test/test_threading.py +++ b/Lib/test/test_threading.py @@ -617,6 +617,52 @@ class ThreadTests(BaseTestCase): t.join() self.assertRaises(ValueError, bs.release)

+

+

+

+

+

+

+

+

+ + class ThreadJoinOnShutdown(BaseTestCase): def _run_and_join(self, script): @@ -701,6 +747,10 @@ class ThreadJoinOnShutdown(BaseTestCase) import sys import time import threading

+

thread_has_run = set()

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,10 @@ Projected release date: 2013-11-24 Core and Builtins ----------------- +- Issue #19466: Clear the frames of daemon threads earlier during the

--- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -576,11 +576,13 @@ Py_Finalize(void) _Py_Finalizing = tstate; initialized = 0;

-

/* Collect garbage. This may call finalizers; it's nice to call these * before all modules are destroyed. @@ -595,6 +597,7 @@ Py_Finalize(void) * XXX I haven't seen a real-life report of either of these. / PyGC_Collect(); + #ifdef COUNT_ALLOCS / With COUNT_ALLOCS, it helps to run GC multiple times: each collection might release some types from the type @@ -602,6 +605,13 @@ Py_Finalize(void) while (PyGC_Collect() > 0) /* nothing */; #endif +

+

+ /* Destroy all modules */ PyImport_Cleanup();