python program stop and wait