diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2009-10-18 18:27:17 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2009-10-18 18:27:17 (GMT) |
commit | be4d8094c0098b3e3fcd8ada5fe2b0f9a43a2056 (patch) | |
tree | ac0bbd2a21dbfca146fc530c6cac3509de6b2b71 /Lib/test/test_threading.py | |
parent | 01458c7a62cb3fc79e84e7326c5553e8143c4760 (diff) | |
download | cpython-be4d8094c0098b3e3fcd8ada5fe2b0f9a43a2056.zip cpython-be4d8094c0098b3e3fcd8ada5fe2b0f9a43a2056.tar.gz cpython-be4d8094c0098b3e3fcd8ada5fe2b0f9a43a2056.tar.bz2 |
Merged revisions 75499 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r75499 | antoine.pitrou | 2009-10-18 20:22:04 +0200 (dim., 18 oct. 2009) | 3 lines
Add a test for same-thread asynchronous exceptions (see #1779233).
........
Diffstat (limited to 'Lib/test/test_threading.py')
-rw-r--r-- | Lib/test/test_threading.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py index 500a114..8ce480e 100644 --- a/Lib/test/test_threading.py +++ b/Lib/test/test_threading.py @@ -162,6 +162,25 @@ class ThreadTests(unittest.TestCase): exception = ctypes.py_object(AsyncExc) + # First check it works when setting the exception from the same thread. + tid = _thread.get_ident() + + try: + result = set_async_exc(ctypes.c_long(tid), exception) + # The exception is async, so we might have to keep the VM busy until + # it notices. + while True: + pass + except AsyncExc: + pass + else: + self.fail("AsyncExc not raised") + try: + self.assertEqual(result, 1) # one thread state modified + except UnboundLocalError: + # The exception was raised to quickly for us to get the result. + pass + # `worker_started` is set by the thread when it's inside a try/except # block waiting to catch the asynchronously set AsyncExc exception. # `worker_saw_exception` is set by the thread upon catching that |