def wait_on_event(event, timeout=None):
if timeout is not None:<EOL><INDENT>event.wait(timeout)<EOL>return<EOL><DEDENT>if six.PY2:<EOL><INDENT>while not event.is_set():<EOL><INDENT>event.wait(sys.maxint)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>event.wait()<EOL><DEDENT>
Waits on a single threading Event, with an optional timeout.

This is here for compatibility reasons as python 2 can't reliably wait
on an event without a timeout and python 3 doesn't define a `maxint`.