[Python-Dev] uthread strawman
Moshe Zadka <firstname.lastname@example.org>
Thu, 9 Nov 2000 16:38:30 +0200 (IST)
> Does anybody know of a useful example where continuations
> are really needed?
> Well, it may be a bit unpythonic (for several reasons), but restartable
> exceptions AFAICS cannot be implemented by generators or coroutines.
> Restartable exceptions are not always appropriate, but tend to be
> a pain to simulate when they are needed.
> How would restartable exceptions work? Like so?
> try: # here, a continuation is saved
> pass # some operations which may fail,
> # raising something that inherits from RestartableException
> except RestartableException:
> pass # repair the condition
> sys.try_again() # go back to the try statement
I imagined something like
raise RestartableException, continuation.current_continuation()
except RestartableException, ex:
# correct the problem
IOW, just put the continuation in the exception object.
I don't think you can use generators/coroutines to simulate something
Moshe Zadka <email@example.com> -- 95855124