fix waitforthreads for Python >= 3.4
release 3.1.1: fix waitforthreads to support Python >= 3.4