Fix return value of Condition.wait()

Condition.wait() is not documented to return anything, and the Python
implementation does not return anything. pthreading used to return the
error code from the underlying pthread_cond_wait() and
pthread_cond_timedwait() functions. This patch removes the return value
from Condition.wait().

Signed-off-by: Nir Soffer <nsoffer@redhat.com>
Fix handling of spurious wakeups during wait

Spurious wakeups from the pthread_cond_timedwait() or
pthread_cond_wait() functions may occur, causing Event.wait to return
before the specified timeout has passed, or before the event was set.
This behaviour is not documented in the Python Event or Condition
objects, and is not expected by client code.

Client code using Event.wait() could use the following pattern to handle
spurious returns:

    while not event.is_set():
        event.wait()

Client code using Event.wait(timeout) has *no* good way to detect and
handle a spurious return. This is easy to do using
pthread_cond_timewait, because it accepts an absolute time instead of a
relative timeout.

This patch fixes Event.wait() so it work as described in the Python
documentation, eliminating the need for wait loops in client code.

The fix adds a non-standard Condition.wait_until(bailout) method,
accepting an absolute time instead of relative time, and returning True
if the bailout time has passed. Using the new method, Event.wait can be
reimplemented correctly, handling spurious returns from the underlying
implementation. The new Event class replaces the threading.Event when
monkey-patching.

Behaviour changes in this patch:

- Event.wait() return only when the condition is notified.
- Event.wait(timeout) return only if the condition was notified, or the
  timeout expired.

The behavior of Condition object is not changed, except the addition of
wait_until() method.

Signed-off-by: Nir Soffer <nsoffer@redhat.com>
Update README.md about reimplented objects

Mention the new Event object and add missing RLock object, and update
the text describing the new objects.

Signed-off-by: Nir Soffer <nsoffer@redhat.com>
Added missing period in README.md

Signed-off-by: Saggi Mizrahi <ficoos@gmail.com>