Janzert wrote: > Eric Pruitt wrote: >> Sounds good enough to me but I was wondering if it might be a good >> idea to add a function like "pidinuse" to subprocess as a whole that >> would determine if a process ID was being used and return a simple >> boolean value. I came across a number of people searching for a way to >> determine if a PID was running (Google "python check if pid exists") >> so it seems like the implemented functionality would be of use to the >> community as a whole, not just my wrapper class. >> >> Eric >> > > I'm not sure of the actual details but it seems from your description > that even if you check first a race condition will still exist. > Specifically the subprocess could terminate after the check and before > the TerminateProcess call. So it seems better just to call > TerminateProcess and then correctly handle any possible error. Janzert is correct here - this is a case where ruling out the error completely is impossible, so you're going to have to handle it regardless. A cross platform way of checking if a particular subprocess is still running might be an interesting feature in its own right, but I don't think it will prevent this exception. Cheers, Nick. -- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia ---------------------------------------------------------------
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4