[Python-checkins] cpython: Replace an overly optimistic assert() in _PyGC_CollectNoFail with a simple
antoine.pitrou
python-checkins at python.org
Thu Aug 15 20:15:27 CEST 2013
http://hg.python.org/cpython/rev/351657165a05
changeset: 85180:351657165a05
user: Antoine Pitrou <solipsis at pitrou.net>
date: Thu Aug 15 20:15:15 2013 +0200
summary:
Replace an overly optimistic assert() in _PyGC_CollectNoFail with a simple guard.
files:
Modules/gcmodule.c | 19 +++++++++++++------
1 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/Modules/gcmodule.c b/Modules/gcmodule.c
--- a/Modules/gcmodule.c
+++ b/Modules/gcmodule.c
@@ -1612,12 +1612,19 @@
{
Py_ssize_t n;
- /* This function should only be called on interpreter shutdown, and
- therefore not recursively. */
- assert(!collecting);
- collecting = 1;
- n = collect(NUM_GENERATIONS - 1, NULL, NULL, 1);
- collecting = 0;
+ /* Ideally, this function is only called on interpreter shutdown,
+ and therefore not recursively. Unfortunately, when there are daemon
+ threads, a daemon thread can start a cyclic garbage collection
+ during interpreter shutdown (and then never finish it).
+ See http://bugs.python.org/issue8713#msg195178 for an example.
+ */
+ if (collecting)
+ n = 0;
+ else {
+ collecting = 1;
+ n = collect(NUM_GENERATIONS - 1, NULL, NULL, 1);
+ collecting = 0;
+ }
return n;
}
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list