[Python-Dev] PEP 334 - Simple Coroutines via SuspendIteration

Clark C. Evans cce at clarkevans.com
Wed Sep 8 21:20:57 CEST 2004


On Wed, Sep 08, 2004 at 08:58:21PM +0200, Samuele Pedroni wrote:
| If I understand the proposal (which is quite vague), like restartable 
| syscalls, there is also the matter that whatever raised the 
| SuspendIteration should be retried on resumption of the generator, e.g 
| calling nested generator next.

That's exactly the idea.  The SuspendIteration exception could contain,
however, the file/socket that it is blocked on, so a smart scheduler
need not be blindly restarting things.

| So one would have to cherry pick for each bytecode or similar abstract
| operations model relevant suspension/resumption points and it would 
| still be quite a daunting task to implement this adding the code
| for intra bytecode resumption. (Of course this assumes that capturing
| the C stack and similar techniques are out of question)

I was assuming that only calls within the generator to next(), implicit
or otherwise, would be suspension points.

This covers all of my use cases anyway.  In the other situations, if
they are even useful, don't do that.  Convert the SuspendIteration to a
RuntimeError, or resume at the previous suspension point?

The idea of the PEP was that a nested-generator context provides this
limited set of suspension points to make an implementation possible.

Kind Regards,

Clark

-- 
Clark C. Evans                      Prometheus Research, LLC.
                                    http://www.prometheusresearch.com/
    o                               office: +1.203.777.2550 
  ~/ ,                              mobile: +1.203.444.0557 
 //
((   Prometheus Research: Transforming Data Into Knowledge
 \\  ,
   \/    - Research Exchange Database
   /\    - Survey & Assessment Technologies
   ` \   - Software Tools for Researchers
    ~ *


More information about the Python-Dev mailing list