mirror of
https://github.com/python/cpython.git
synced 2025-09-07 17:32:01 +00:00
Replace an overly optimistic assert() in _PyGC_CollectNoFail with a simple guard.
This commit is contained in:
parent
37d5cebb48
commit
c69c9bc24b
1 changed files with 13 additions and 6 deletions
|
@ -1612,12 +1612,19 @@ _PyGC_CollectNoFail(void)
|
||||||
{
|
{
|
||||||
Py_ssize_t n;
|
Py_ssize_t n;
|
||||||
|
|
||||||
/* This function should only be called on interpreter shutdown, and
|
/* Ideally, this function is only called on interpreter shutdown,
|
||||||
therefore not recursively. */
|
and therefore not recursively. Unfortunately, when there are daemon
|
||||||
assert(!collecting);
|
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;
|
collecting = 1;
|
||||||
n = collect(NUM_GENERATIONS - 1, NULL, NULL, 1);
|
n = collect(NUM_GENERATIONS - 1, NULL, NULL, 1);
|
||||||
collecting = 0;
|
collecting = 0;
|
||||||
|
}
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue