First - yay python! Love python myself!
What sample code are you speaking of? The sample straight from AsyncLabs (with no mods) or some variant of the sample found elsewhere (on this thread for example)? Posting your code is always helpful

This sample (direct from AsyncLabs) is built in a way that it has a small conversation with the PC and then "hangs up" the conversation. In order to get it to do what you want you will have to dissect it a bit (e.g. to keep the connection open). That said, you will be better off having the WiShield be the "server" (accepting connections) rather than the "client" (originating connections). I have found the WiShield to be rock solid as the "server" but sometimes "getting lost" when it is the client and the originator of the connection.
If you go look at this post
http://asynclabs.com/forums/viewtopic.php?f=18&t=178 you will find some sample code that uses UDP and the Parallax PING))) sensor. Fair warning this project runs in "client mode" and sometimes gets lost.
Greg