Use Popen.communicate instead of Popen.wait
Merge pull request by cedricmessiant: Fix sub process deadlock by using Popen.wait.