]> granicus.if.org Git - python/commitdiff
#1674032: return value of flag from Event.wait(). OKed by Guido.
authorGeorg Brandl <georg@python.org>
Tue, 31 Mar 2009 20:41:08 +0000 (20:41 +0000)
committerGeorg Brandl <georg@python.org>
Tue, 31 Mar 2009 20:41:08 +0000 (20:41 +0000)
Doc/library/threading.rst
Lib/test/test_threading.py
Lib/threading.py

index 69593ae7b1fd627ffcff3e055d0f3ebfb0bb1738..efd0cff7c34ae4b3a4b325fc00e97f83bf326508 100644 (file)
@@ -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:
 
index c8f9cac8f9c5f583833cc1b6bf4d8b37c3163c11..cb6f6d2ae918f4a1d8d1ede6e4edf78fb12b914a 100644 (file)
@@ -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)
index a776c66752b0dfe74cd06a5611e0d1bd83ceafc7..cc2be1b8605cfefe9b360c1b1cafe53073dbf616 100644 (file)
@@ -391,6 +391,7 @@ class _Event(_Verbose):
         try:
             if not self.__flag:
                 self.__cond.wait(timeout)
+            return self.__flag
         finally:
             self.__cond.release()