There was an error while loading. Please reload this page.
1 parent 37d5ceb commit c69c9bcCopy full SHA for c69c9bc
1 file changed
Modules/gcmodule.c
@@ -1612,12 +1612,19 @@ _PyGC_CollectNoFail(void)
1612
{
1613
Py_ssize_t n;
1614
1615
- /* This function should only be called on interpreter shutdown, and
1616
- therefore not recursively. */
1617
- assert(!collecting);
1618
- collecting = 1;
1619
- n = collect(NUM_GENERATIONS - 1, NULL, NULL, 1);
1620
- 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.
+ */
1621
+ if (collecting)
1622
+ n = 0;
1623
+ else {
1624
+ collecting = 1;
1625
+ n = collect(NUM_GENERATIONS - 1, NULL, NULL, 1);
1626
+ collecting = 0;
1627
+ }
1628
return n;
1629
}
1630
0 commit comments