Ruby has a nice exception handling recovery construct in its 'retry'; using python I needed the same for my ping spewer CookingPacketsWithDugsong as depending on system load, contention would occur and some syscalls would not immediately work.
I solved this by using the following semi-functional code:
I used it in my updated packet spewer as:
A better way probably exists, since init(), start(), and end() could probably at least have parameters. Even worse, I had to set up a tuple return value that indicates failure, so one can't ever return a tuple with None as first value.
I'll switch retry() to raise an error when it finally gives up, and stick the returned sys.exc_info() into that. I need to read further on function calls; first I have to run to my Chinese meetup out here in Seattle....
Switching retry() to use exceptions makes a lot more sense. Now for the function argument passing... and thanks to simple variable argument support, that wraps it up quite nicely.