If a pid stops running before you get around to processing it, it will throw an exception in this for loop. You'll probably want to add a try-except block inside this loop.