views:

32

answers:

2

Hello.

>>> import threading
>>> event = threading.Event()
>>> event.set()
>>> print event.wait(1)
None
>>> event.clear()
>>> print event.wait(1)
None

So it basically returns None both when condition was True and False. How can I distinguish the case of timeouting from the one with no waiting at all? Meanwile, the docs say

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.

Am I missing something?

+3  A: 

Yes, you're missing next sentence in documentation which writes:

Changed in version 2.7: Previously, the method always returned None.

Michal Čihař
Oh, reading the next sentence has always been the hard part)
roddik
+1  A: 

From the docs for threading.Event.wait:

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.

Changed in version 2.7: Previously, the method always returned None.

Which version of python are you using?

nosklo
I guess most certainly not 2.7
SilentGhost