[Python-checkins] r70883 - in python/trunk: Doc/library/threading.rst Lib/test/test_threading.py Lib/threading.py

georg.brandl python-checkins at python.org
Tue Mar 31 22:41:09 CEST 2009


Author: georg.brandl
Date: Tue Mar 31 22:41:08 2009
New Revision: 70883

Log:
#1674032: return value of flag from Event.wait(). OKed by Guido.

Modified:
   python/trunk/Doc/library/threading.rst
   python/trunk/Lib/test/test_threading.py
   python/trunk/Lib/threading.py

Modified: python/trunk/Doc/library/threading.rst
==============================================================================
--- python/trunk/Doc/library/threading.rst	(original)
+++ python/trunk/Doc/library/threading.rst	Tue Mar 31 22:41:08 2009
@@ -696,14 +696,20 @@
 
 .. 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:
 

Modified: python/trunk/Lib/test/test_threading.py
==============================================================================
--- python/trunk/Lib/test/test_threading.py	(original)
+++ python/trunk/Lib/test/test_threading.py	Tue Mar 31 22:41:08 2009
@@ -186,7 +186,8 @@
         # 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)

Modified: python/trunk/Lib/threading.py
==============================================================================
--- python/trunk/Lib/threading.py	(original)
+++ python/trunk/Lib/threading.py	Tue Mar 31 22:41:08 2009
@@ -391,6 +391,7 @@
         try:
             if not self.__flag:
                 self.__cond.wait(timeout)
+            return self.__flag
         finally:
             self.__cond.release()
 


More information about the Python-checkins mailing list