|  | 
| 6 | 6 | import sys | 
| 7 | 7 | import tempfile | 
| 8 | 8 | import textwrap | 
|  | 9 | +import threading | 
| 9 | 10 | import unittest | 
|  | 11 | +from test import support | 
|  | 12 | +from test.support import threading_helper | 
| 10 | 13 | from test.support import verbose | 
| 11 | 14 | from test.support.import_helper import import_module | 
| 12 | 15 | from test.support.os_helper import unlink, temp_dir, TESTFN | 
| @@ -403,5 +406,26 @@ def test_write_read_limited_history(self): | 
| 403 | 406 |         # See TestHistoryManipulation for the full test. | 
| 404 | 407 | 
 | 
| 405 | 408 | 
 | 
|  | 409 | +@unittest.skipUnless(support.Py_GIL_DISABLED, 'these tests can only possibly fail with GIL disabled') | 
|  | 410 | +class FreeThreadingTest(unittest.TestCase): | 
|  | 411 | +    @threading_helper.reap_threads | 
|  | 412 | +    @threading_helper.requires_working_threading() | 
|  | 413 | +    def test_free_threading(self): | 
|  | 414 | +        def completer_delims(b): | 
|  | 415 | +            b.wait() | 
|  | 416 | +            for _ in range(100): | 
|  | 417 | +                readline.get_completer_delims() | 
|  | 418 | +                readline.set_completer_delims(' \t\n`@#%^&*()=+[{]}\\|;:\'",<>?') | 
|  | 419 | +                readline.set_completer_delims(' \t\n`@#%^&*()=+[{]}\\|;:\'",<>?') | 
|  | 420 | +                readline.get_completer_delims() | 
|  | 421 | + | 
|  | 422 | +        count   = 40 | 
|  | 423 | +        barrier = threading.Barrier(count) | 
|  | 424 | +        threads = [threading.Thread(target=completer_delims, args=(barrier,)) for _ in range(count)] | 
|  | 425 | + | 
|  | 426 | +        with threading_helper.start_threads(threads): | 
|  | 427 | +            pass | 
|  | 428 | + | 
|  | 429 | + | 
| 406 | 430 | if __name__ == "__main__": | 
| 407 | 431 |     unittest.main() | 
0 commit comments