process and spinning slash

Fredrik Lundh fredrik at pythonware.com
Sun Oct 30 12:14:03 EST 2005


Alex Martelli wrote:

> Have the spin function accept the pid argument and exit the loop if said
> pid has terminated; to check the latter, e.g., os.kill(pid, 0) -- this
> will raise an OSError if no process with that pid exists, so you can use
> a try/except OSError: to catch that and break as appropriate.

or use the subprocess module instead of fork/exec, pass the Popen instance
to spin, and use the poll() method to check if the process is still running.

</F>






More information about the Python-list mailing list