Fix erratically failing threads_exception python test