beelit94 / python-terraform

MIT License
475 stars 171 forks source link

Use context manager for Popen #41

Open kshpytsya opened 6 years ago

kshpytsya commented 6 years ago

On Python 3.2+ Popen should be used as context manager, otherwise very obscure errors happen on Windows with multiple invocations of Popen.

From https://docs.python.org/3/library/subprocess.html:

with Popen(["ifconfig"], stdout=PIPE) as proc:
    log.write(proc.stdout.read())
beelit94 commented 6 years ago

@kshpytsya thank you for reporting this. it's awesome to identify this issue. I'll look into it this weekend, or you're always welcome to file a PR for this 👍