| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent e755fba commit 15054c1
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -616,51 +616,6 @@ def test_BoundedSemaphore_limit(self): | |||
| 616 | 616 | t.join() | |
| 617 | 617 | self.assertRaises(ValueError, bs.release) | |
| 618 | 618 | ||
| 619 | - def test_locals_at_exit(self): | ||
| 620 | - # Issue #19466: thread locals must not be deleted before destructors | ||
| 621 | - # are called | ||
| 622 | - rc, out, err = assert_python_ok("-c", """if 1: | ||
| 623 | - import threading | ||
| 624 | - | ||
| 625 | - class Atexit: | ||
| 626 | - def __del__(self): | ||
| 627 | - print("thread_dict.atexit = %r" % thread_dict.atexit) | ||
| 628 | - | ||
| 629 | - thread_dict = threading.local() | ||
| 630 | - thread_dict.atexit = "atexit" | ||
| 631 | - | ||
| 632 | - atexit = Atexit() | ||
| 633 | - """) | ||
| 634 | - self.assertEqual(out.rstrip(), b"thread_dict.atexit = 'atexit'") | ||
| 635 | - | ||
| 636 | - def test_warnings_at_exit(self): | ||
| 637 | - # Issue #19466: try to call most destructors at Python shutdown before | ||
| 638 | - # destroying Python thread states | ||
| 639 | - filename = __file__ | ||
| 640 | - rc, out, err = assert_python_ok("-Wd", "-c", """if 1: | ||
| 641 | - import time | ||
| 642 | - import threading | ||
| 643 | - | ||
| 644 | - def open_sleep(): | ||
| 645 | - # a warning will be emitted when the open file will be | ||
| 646 | - # destroyed (without being explicitly closed) while the daemon | ||
| 647 | - # thread is destroyed | ||
| 648 | - fileobj = open(%a, 'rb') | ||
| 649 | - start_event.set() | ||
| 650 | - time.sleep(60.0) | ||
| 651 | - | ||
| 652 | - start_event = threading.Event() | ||
| 653 | - | ||
| 654 | - thread = threading.Thread(target=open_sleep) | ||
| 655 | - thread.daemon = True | ||
| 656 | - thread.start() | ||
| 657 | - | ||
| 658 | - # wait until the thread started | ||
| 659 | - start_event.wait() | ||
| 660 | - """ % filename) | ||
| 661 | - self.assertRegex(err.rstrip(), | ||
| 662 | - b"^sys:1: ResourceWarning: unclosed file ") | ||
| 663 | - | ||
| 664 | 619 | @cpython_only | |
| 665 | 620 | def test_frame_tstate_tracing(self): | |
| 666 | 621 | # Issue #14432: Crash when a generator is created in a C thread that is | |
@@ -786,10 +741,6 @@ def test_4_daemon_threads(self): | |||
| 786 | 741 | import sys | |
| 787 | 742 | import time | |
| 788 | 743 | import threading | |
| 789 | - import warnings | ||
| 790 | - | ||
| 791 | - # ignore "unclosed file ..." warnings | ||
| 792 | - warnings.filterwarnings('ignore', '', ResourceWarning) | ||
| 793 | 744 | ||
| 794 | 745 | thread_has_run = set() | |
| 795 | 746 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -10,6 +10,10 @@ Release date: 2014-02-23 | |||
| 10 | 10 | Core and Builtins | |
| 11 | 11 | ----------------- | |
| 12 | 12 | ||
| 13 | + - Issue #20526: Revert changes of issue #19466 which introduces a regression: | ||
| 14 | + don't clear anymore the state of Python threads early during the Python | ||
| 15 | + shutdown. | ||
| 16 | + | ||
| 13 | 17 | - Issue #20595: Make getargs.c C89 compliant. | |
| 14 | 18 | ||
| 15 | 19 | Library | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -582,13 +582,11 @@ Py_Finalize(void) | |||
| 582 | 582 | _Py_Finalizing = tstate; | |
| 583 | 583 | initialized = 0; | |
| 584 | 584 | ||
| 585 | - /* Destroy the state of all threads except of the current thread: in | ||
| 586 | - practice, only daemon threads should still be alive. Clear frames of | ||
| 587 | - other threads to call objects destructor. Destructors will be called in | ||
| 588 | - the current Python thread. Since _Py_Finalizing has been set, no other | ||
| 589 | - Python threads can lock the GIL at this point (if they try, they will | ||
| 590 | - exit immediately). */ | ||
| 591 | - _PyThreadState_DeleteExcept(tstate); | ||
| 585 | + /* Flush stdout+stderr */ | ||
| 586 | + flush_std_files(); | ||
| 587 | + | ||
| 588 | + /* Disable signal handling */ | ||
| 589 | + PyOS_FiniInterrupts(); | ||
| 592 | 590 | ||
| 593 | 591 | /* Collect garbage. This may call finalizers; it's nice to call these | |
| 594 | 592 | * before all modules are destroyed. | |
@@ -603,21 +601,13 @@ Py_Finalize(void) | |||
| 603 | 601 | * XXX I haven't seen a real-life report of either of these. | |
| 604 | 602 | */ | |
| 605 | 603 | PyGC_Collect(); | |
| 606 | - | ||
| 607 | 604 | #ifdef COUNT_ALLOCS | |
| 608 | 605 | /* With COUNT_ALLOCS, it helps to run GC multiple times: | |
| 609 | 606 | each collection might release some types from the type | |
| 610 | 607 | list, so they become garbage. */ | |
| 611 | 608 | while (PyGC_Collect() > 0) | |
| 612 | 609 | /* nothing */; | |
| 613 | 610 | #endif | |
| 614 | - | ||
| 615 | - /* Flush stdout+stderr */ | ||
| 616 | - flush_std_files(); | ||
| 617 | - | ||
| 618 | - /* Disable signal handling */ | ||
| 619 | - PyOS_FiniInterrupts(); | ||
| 620 | - | ||
| 621 | 611 | /* Destroy all modules */ | |
| 622 | 612 | PyImport_Cleanup(); | |
| 623 | 613 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments