Mercurial > cpython-lru_cache-weakref
comparison Python/pythonrun.c @ 31058:bf7df48012cb 2.3
Py_Finalize(): disabled the second call of cyclic gc, and added extensive
comments about why both calls to cyclic gc here can cause problems.
Already fixed on the trunk. Since the calls were introduced in 2.3,
that's the end of it.
| author | Tim Peters <tim.peters@gmail.com> |
|---|---|
| date | Mon, 01 Dec 2003 22:13:12 +0000 |
| parents | e3ebd740d1ef |
| children | 164ce1bcab6e |
comparison
equal
deleted
inserted
replaced
| 31055:38338c970f7d | 31058:bf7df48012cb |
|---|---|
| 330 /* drop module references we saved */ | 330 /* drop module references we saved */ |
| 331 Py_XDECREF(warnings_module); | 331 Py_XDECREF(warnings_module); |
| 332 warnings_module = NULL; | 332 warnings_module = NULL; |
| 333 | 333 |
| 334 /* Collect garbage. This may call finalizers; it's nice to call these | 334 /* Collect garbage. This may call finalizers; it's nice to call these |
| 335 before all modules are destroyed. */ | 335 * before all modules are destroyed. |
| 336 * XXX If a __del__ or weakref callback is triggered here, and tries to | |
| 337 * XXX import a module, bad things can happen, because Python no | |
| 338 * XXX longer believes it's initialized. | |
| 339 * XXX Fatal Python error: Interpreter not initialized (version mismatch?) | |
| 340 * XXX is easy to provoke that way. I've also seen, e.g., | |
| 341 * XXX Exception exceptions.ImportError: 'No module named sha' | |
| 342 * XXX in <function callback at 0x008F5718> ignored | |
| 343 * XXX but I'm unclear on exactly how that one happens. In any case, | |
| 344 * XXX I haven't seen a real-life report of either of these. | |
| 345 */ | |
| 336 PyGC_Collect(); | 346 PyGC_Collect(); |
| 337 | 347 |
| 338 /* Destroy all modules */ | 348 /* Destroy all modules */ |
| 339 PyImport_Cleanup(); | 349 PyImport_Cleanup(); |
| 340 | 350 |
| 341 /* Collect final garbage. This disposes of cycles created by | 351 /* Collect final garbage. This disposes of cycles created by |
| 342 new-style class definitions, for example. */ | 352 * new-style class definitions, for example. |
| 353 * XXX This is disabled because it caused too many problems. If | |
| 354 * XXX a __del__ or weakref callback triggers here, Python code has | |
| 355 * XXX a hard time running, because even the sys module has been | |
| 356 * XXX cleared out (sys.stdout is gone, sys.excepthook is gone, etc). | |
| 357 * XXX One symptom is a sequence of information-free messages | |
| 358 * XXX coming from threads (if a __del__ or callback is invoked, | |
| 359 * XXX other threads can execute too, and any exception they encounter | |
| 360 * XXX triggers a comedy of errors as subsystem after subsystem | |
| 361 * XXX fails to find what it *expects* to find in sys to help report | |
| 362 * XXX the exception and consequent unexpected failures). I've also | |
| 363 * XXX seen segfaults then, after adding print statements to the | |
| 364 * XXX Python code getting called. | |
| 365 */ | |
| 366 #if 0 | |
| 343 PyGC_Collect(); | 367 PyGC_Collect(); |
| 368 #endif | |
| 344 | 369 |
| 345 /* Destroy the database used by _PyImport_{Fixup,Find}Extension */ | 370 /* Destroy the database used by _PyImport_{Fixup,Find}Extension */ |
| 346 _PyImport_Fini(); | 371 _PyImport_Fini(); |
| 347 | 372 |
| 348 /* Debugging stuff */ | 373 /* Debugging stuff */ |
