(case_setup_multiprocessing, file_to_check)
| 2791 | ], |
| 2792 | ) |
| 2793 | def test_multiprocessing_simple(case_setup_multiprocessing, file_to_check): |
| 2794 | import threading |
| 2795 | from tests_python.debugger_unittest import AbstractWriterThread |
| 2796 | |
| 2797 | with case_setup_multiprocessing.test_file(file_to_check) as writer: |
| 2798 | break1_line = writer.get_line_index_with_content("break 1 here") |
| 2799 | break2_line = writer.get_line_index_with_content("break 2 here") |
| 2800 | |
| 2801 | writer.write_add_breakpoint(break1_line) |
| 2802 | writer.write_add_breakpoint(break2_line) |
| 2803 | |
| 2804 | server_socket = writer.server_socket |
| 2805 | |
| 2806 | class SecondaryProcessWriterThread(AbstractWriterThread): |
| 2807 | TEST_FILE = writer.get_main_filename() |
| 2808 | _sequence = -1 |
| 2809 | |
| 2810 | class SecondaryProcessThreadCommunication(threading.Thread): |
| 2811 | def run(self): |
| 2812 | from tests_python.debugger_unittest import ReaderThread |
| 2813 | |
| 2814 | expected_connections = 2 if sys.platform == "darwin" else 1 |
| 2815 | |
| 2816 | for _ in range(expected_connections): |
| 2817 | server_socket.listen(1) |
| 2818 | self.server_socket = server_socket |
| 2819 | new_sock, addr = server_socket.accept() |
| 2820 | |
| 2821 | reader_thread = ReaderThread(new_sock) |
| 2822 | reader_thread.name = " *** Multiprocess Reader Thread" |
| 2823 | reader_thread.start() |
| 2824 | |
| 2825 | writer2 = SecondaryProcessWriterThread() |
| 2826 | |
| 2827 | writer2.reader_thread = reader_thread |
| 2828 | writer2.sock = new_sock |
| 2829 | |
| 2830 | writer2.write_version() |
| 2831 | writer2.write_add_breakpoint(break1_line) |
| 2832 | writer2.write_add_breakpoint(break2_line) |
| 2833 | writer2.write_make_initial_run() |
| 2834 | |
| 2835 | hit = writer2.wait_for_breakpoint_hit() |
| 2836 | writer2.write_run_thread(hit.thread_id) |
| 2837 | |
| 2838 | secondary_process_thread_communication = SecondaryProcessThreadCommunication() |
| 2839 | secondary_process_thread_communication.start() |
| 2840 | writer.write_make_initial_run() |
| 2841 | hit2 = writer.wait_for_breakpoint_hit() |
| 2842 | secondary_process_thread_communication.join(10) |
| 2843 | if secondary_process_thread_communication.is_alive(): |
| 2844 | raise AssertionError("The SecondaryProcessThreadCommunication did not finish") |
| 2845 | writer.write_run_thread(hit2.thread_id) |
| 2846 | writer.finished_ok = True |
| 2847 | |
| 2848 | |
| 2849 | @pytest.mark.skipif(not IS_CPYTHON, reason="CPython only test.") |
nothing calls this directly
no test coverage detected