Make the gc.collect() function respect the collection lock. This fixes

SF bug 476129: "gc.collect sometimes hangs".
This commit is contained in:
Neil Schemenauer 2001-10-31 23:09:35 +00:00
parent 67050d2d64
commit e8c40cb722

View File

@ -548,10 +548,17 @@ gc_collect(PyObject *self, PyObject *args)
if (!PyArg_ParseTuple(args, ":collect")) /* check no args */
return NULL;
if (collecting) {
n = 0; /* already collecting, don't do anything */
}
else {
collecting = 1;
generation = 2;
gc_list_merge(&_PyGC_generation0, &generation2);
gc_list_merge(&generation1, &generation2);
n = collect(&generation2, &generation2);
collecting = 0;
}
return Py_BuildValue("l", n);
}