The Python Oracle

Killing shell=True process results in ResourceWarning: subprocess is still running

Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn

--

Music by Eric Matyas
https://www.soundimage.org
Track title: The World Wide Mind

--

Chapters
00:00 Question
01:04 Accepted answer (Score 8)
01:27 Thank you

--

Full question
https://stackoverflow.com/questions/5247...

Question links:
[How to terminate a python subprocess launched with shell=True]: https://stackoverflow.com/questions/4789...

Accepted answer links:
[zombie process]: https://en.wikipedia.org/wiki/Zombie_pro...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #subprocess

#avk47



ACCEPTED ANSWER

Score 11


You didn't wait for the process to end. Even if you kill the process, you're still supposed to wait for it so you don't have a zombie process hanging around. Python is warning you that you didn't wait.

Add a process.wait() call after killing it.