diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2013-08-15 18:15:15 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2013-08-15 18:15:15 (GMT) |
commit | c69c9bc24bd8ea79775f1be025202d81ea800f0f (patch) | |
tree | d0bc2b394c44f1cb78ac2e22dfb59fe15f9aeb05 /Modules/gcmodule.c | |
parent | 37d5cebb4816a96785a85db9dcfd8519f30df18b (diff) | |
download | cpython-c69c9bc24bd8ea79775f1be025202d81ea800f0f.zip cpython-c69c9bc24bd8ea79775f1be025202d81ea800f0f.tar.gz cpython-c69c9bc24bd8ea79775f1be025202d81ea800f0f.tar.bz2 |
Replace an overly optimistic assert() in _PyGC_CollectNoFail with a simple guard.
Diffstat (limited to 'Modules/gcmodule.c')
-rw-r--r-- | Modules/gcmodule.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/Modules/gcmodule.c b/Modules/gcmodule.c index 02e0cb8..a84d752 100644 --- a/Modules/gcmodule.c +++ b/Modules/gcmodule.c @@ -1612,12 +1612,19 @@ _PyGC_CollectNoFail(void) { 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; } |