If you want the restart, you need to take advantage of the PEP-342 two-way yield(), as in:
...
except SomethingBad:
yield None
restartRequest = yield None
if restartRequest:
do whatever is necessary to go on
The problem with the above is that the double yield() ugly. You cannot do this with single yield() because the caller would have to know in advance that next() will return None.
Comments
If you want the restart, you need to take advantage of the PEP-342 two-way yield(), as in:
The problem with the above is that the double yield() ugly. You cannot do this with single yield() because the caller would have to know in advance that next() will return None.