summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Doc/library/threading.rst12
-rw-r--r--Lib/test/test_threading.py3
-rw-r--r--Lib/threading.py1
3 files changed, 12 insertions, 4 deletions
diff --git a/Doc/library/threading.rst b/Doc/library/threading.rst
index 69593ae..efd0cff 100644
--- a/Doc/library/threading.rst
+++ b/Doc/library/threading.rst
@@ -696,14 +696,20 @@ An event object manages an internal flag that can be set to true with the
.. method:: Event.wait([timeout])
- Block until the internal flag is true. If the internal flag is true on entry,
- return immediately. Otherwise, block until another thread calls :meth:`set` to
- set the flag to true, or until the optional timeout occurs.
+ Block until the internal flag is true. If the internal flag is true on entry,
+ return immediately. Otherwise, block until another thread calls :meth:`set`
+ to set the flag to true, or until the optional timeout occurs.
When the timeout argument is present and not ``None``, it should be a floating
point number specifying a timeout for the operation in seconds (or fractions
thereof).
+ This method returns the internal flag on exit, so it will always return
+ ``True`` except if a timeout is given and the operation times out.
+
+ .. versionchanged:: 2.7
+ Previously, the method always returned ``None``.
+
.. _timer-objects:
diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py
index c8f9cac..cb6f6d2 100644
--- a/Lib/test/test_threading.py
+++ b/Lib/test/test_threading.py
@@ -186,7 +186,8 @@ class ThreadTests(unittest.TestCase):
# Now raise an exception in the worker thread.
if verbose:
print " waiting for worker thread to get started"
- worker_started.wait()
+ ret = worker_started.wait()
+ self.assertTrue(ret)
if verbose:
print " verifying worker hasn't exited"
self.assert_(not t.finished)
diff --git a/Lib/threading.py b/Lib/threading.py
index a776c66..cc2be1b 100644
--- a/Lib/threading.py
+++ b/Lib/threading.py
@@ -391,6 +391,7 @@ class _Event(_Verbose):
try:
if not self.__flag:
self.__cond.wait(timeout)
+ return self.__flag
finally:
self.__cond.release()