[Python-Dev] uthread strawman

Moshe Zadka moshez at math.huji.ac.il
Thu Nov 9 15:38:30 CET 2000


[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 at math.huji.ac.il> -- 95855124
http://advogato.org/person/moshez



More information about the Stackless mailing list