|
13 | 13 | from unittest.mock import ANY |
14 | 14 | from test.support import ( |
15 | 15 | os_helper, |
| 16 | + threading_helper, |
16 | 17 | SHORT_TIMEOUT, |
17 | 18 | busy_retry, |
18 | 19 | requires_gil_enabled, |
@@ -3544,6 +3545,36 @@ def gen(): |
3544 | 3545 | skip_non_matching_threads=True, |
3545 | 3546 | ) |
3546 | 3547 |
|
| 3548 | + @unittest.skipIf( |
| 3549 | + sys.platform == "linux" and not PROCESS_VM_READV_SUPPORTED, |
| 3550 | + "Test only runs on Linux with process_vm_readv support", |
| 3551 | + ) |
| 3552 | + @requires_gil_enabled() |
| 3553 | + @threading_helper.requires_working_threading() |
| 3554 | + def test_filtered_active_thread_is_not_replaced(self): |
| 3555 | + samples = [] |
| 3556 | + |
| 3557 | + def sample(): |
| 3558 | + for kwargs in ({"all_threads": True}, |
| 3559 | + {"only_active_thread": True}): |
| 3560 | + unwinder = RemoteUnwinder( |
| 3561 | + os.getpid(), mode=PROFILING_MODE_EXCEPTION, **kwargs, |
| 3562 | + ) |
| 3563 | + samples.append( |
| 3564 | + self._get_thread_statuses(unwinder.get_stack_trace()) |
| 3565 | + ) |
| 3566 | + |
| 3567 | + thread = threading.Thread(target=sample) |
| 3568 | + try: |
| 3569 | + raise ValueError |
| 3570 | + except ValueError: |
| 3571 | + thread.start() |
| 3572 | + threading_helper.join_thread(thread) |
| 3573 | + |
| 3574 | + all_threads, active_thread = samples |
| 3575 | + self.assertEqual(list(all_threads), [threading.get_native_id()]) |
| 3576 | + self.assertEqual(active_thread, {}) |
| 3577 | + |
3547 | 3578 |
|
3548 | 3579 | @requires_remote_subprocess_debugging() |
3549 | 3580 | class TestFrameCaching(RemoteInspectionTestBase): |
|
0 commit comments