A question about the posibility of raise-yield in Python
Дамјан Георгиевски
gdamjan at gmail.com
Wed Jun 30 03:13:17 EDT 2010
> 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??
Recently (ok, several hours ago) I've come up to Greenlets [1] and it
seems they implement exactly what I was asking for, in a C extension!!
It's too bad that Python doesn't support this by default and many
libraries won't make use of it by default. Gevent [2] for example, has
to monkey-patch Python's socket, time.sleep and other modules so that
things like urllib work with it.
I'll continue to read now.
[1] http://codespeak.net/py/0.9.2/greenlet.html
[2] http://www.gevent.org/
> 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.
--
дамјан ((( http://damjan.softver.org.mk/ )))
Please remember 43% of statistics are made on the spot.
More information about the Python-list
mailing list