gh-123321: readline should be thread-safe and not crash
(self)
| 371 | |
| 372 | @requires_working_threading() |
| 373 | def test_gh123321_threadsafe(self): |
| 374 | """gh-123321: readline should be thread-safe and not crash""" |
| 375 | script = textwrap.dedent(r""" |
| 376 | import threading |
| 377 | from test.support.threading_helper import join_thread |
| 378 | |
| 379 | def func(): |
| 380 | input() |
| 381 | |
| 382 | thread1 = threading.Thread(target=func) |
| 383 | thread2 = threading.Thread(target=func) |
| 384 | thread1.start() |
| 385 | thread2.start() |
| 386 | join_thread(thread1) |
| 387 | join_thread(thread2) |
| 388 | print("done") |
| 389 | """) |
| 390 | |
| 391 | output = run_pty(script, input=b"input1\rinput2\r") |
| 392 | |
| 393 | self.assertIn(b"done", output) |
| 394 | |
| 395 | |
| 396 | def test_write_read_limited_history(self): |