[Python-checkins] r75500 - in python/branches/py3k: Lib/test/test_threading.py
python-checkins at python.org
Sun Oct 18 20:27:18 CEST 2009
Date: Sun Oct 18 20:27:17 2009
New Revision: 75500
Merged revisions 75499 via svnmerge from
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).
python/branches/py3k/ (props changed)
--- python/branches/py3k/Lib/test/test_threading.py (original)
+++ python/branches/py3k/Lib/test/test_threading.py Sun Oct 18 20:27:17 2009
@@ -162,6 +162,25 @@
exception = ctypes.py_object(AsyncExc)
+ # First check it works when setting the exception from the same thread.
+ tid = _thread.get_ident()
+ 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:
+ except AsyncExc:
+ self.fail("AsyncExc not raised")
+ self.assertEqual(result, 1) # one thread state modified
+ except UnboundLocalError:
+ # The exception was raised to quickly for us to get the result.
# `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
More information about the Python-checkins