test_threading: use Popen.communicate() instead of .wait()

Popen.communicate() avoids deadlocks and close the pipes when done. This commit
fixes a ResourceWarning(unclosed pipe).
1 file changed