[Python-Dev] uthread strawman

Moshe Zadka Moshe Zadka <moshez@math.huji.ac.il>
Thu, 9 Nov 2000 16:38:30 +0200 (IST)


[Christian Tismer]
> Does anybody know of a useful example where continuations
> are really needed?

[Moshe Zadka]
> 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.

[Christian Tismer]
> 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

try:
	raise RestartableException, continuation.current_continuation()
except RestartableException, ex:
	# correct the problem
	ex.saved_continuation()

IOW, just put the continuation in the exception object.
I don't think you can use generators/coroutines to simulate something
like this
--
Moshe Zadka <moshez@math.huji.ac.il> -- 95855124
http://advogato.org/person/moshez