Use threading.Event to less chance of race cond

that seems to be causing intermittent Travis CI failures.