A question about the posibility of raise-yield in Python
tjreedy at udel.edu
Thu Apr 15 12:30:40 EDT 2010
On 4/15/2010 9:34 AM, Дамјан Георгиевски wrote:
> I'm writing this as a complete newbie (on the issue), so don't be
> surprised if it's the stupidest idea ever.
> I was wondering if there was ever a discusision in the python community
> on a 'raise-yield' kind-of combined expression. I'd like to know if it
> was proposed/rejected/discussed/not-decided yet??
The idea of resumable exceptions has been discussed and so far rejected.
I presume the cost in complication of both the language and
implementations is seen as too high.
> A 'raise-yield' expression would break the flow of a program just like
> an exception, going up the call stack until it would be handled, but
> also like yield it would be possible to continue the flow of the program
> from where it was raise-yield-ed.
> This would be usefull for example in event based frameworks, they could
> just replace socket.* and similar, normally blocking, modules/functions
> with it's own 'raise-yield' enabled ones.
> Then you could just take any normal imperative code that calls normal
> library networking code (say smtplib, poplib or httplib) nad run it in a
> event framework.
> The normal xxxlib calls at some point would get to the now non-blocking,
> event based socket write/read, break the flow back to the event
> framework, and when it finishes the event framework would continue the
> normal flow of the program past the raise-yield.
More information about the Python-list