[ python-Feature Requests-1674032 ] Make threading.Event().wait(timeout=3) return isSet

SourceForge.net noreply at sourceforge.net
Mon Mar 5 14:33:33 CET 2007


Feature Requests item #1674032, was opened at 2007-03-05 15:33
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1674032&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Threads
Group: Python 2.6
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: David Fraser (davidfraser)
Assigned to: Nobody/Anonymous (nobody)
Summary: Make threading.Event().wait(timeout=3) return isSet

Initial Comment:
Currently the wait method on threading.Event always returns None, even if a timeout is given and the event is not set.
This means that there is no way to determine whether the wait method returned because the event was set, or because the timeout period expired, without querying the event status again:

x.wait(3)
if x.isSet():
  # do stuff

Note that in the above case, the event could be cleared between the return from x.wait and the execution of x.isSet (in another thread), and so this would operate as though x.wait had just timed out

It would be great to be able to do:

if x.wait(3):
  # do stuff

This should also not affect any existing code as it shouldn't be relying on the return value from x.wait anyway

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1674032&group_id=5470


More information about the Python-bugs-list mailing list