icmp ping
Don't you have a way here to just take the state you just created? It seems pointless to me to take them all since you're only interested in the latest created anyway
icmp ping
It all makes more or less sense to me. Unfortunately I'm not a Python expert so I'm not entirely sure about some things but I don't have time to check them now.