Ideas for yielding and exception raising

Peter Hansen peter at
Sat Jun 5 13:38:55 CEST 2004

Calvin Spealman wrote:

> I was wondering if it was possible, now or with a patch, to do either of the
> following:
> 1) Cause another thread's most recent function, or a given function in a
> given thread, to yield its generator immediately, such that the generator
> can be used to pick back up where it left off. That is, the function itself
> wouldn't need an actually yield keyword. Could be used to allow a function
> to be controlled in how much time it has per second or somewhat?
> 2) Cause an exception to be raised in all threads that have a reference to a
> given object, as if the object itself is raising the exception. This would
> allow functions to return Monitor Objects that would raise exceptions if
> something bad happened. For example, maybe you want the function to run
> continually until someone else requests access to some syncronized data,
> and the Monitor would raise the exception at that time.

Wouldn't it be better for both of these situations to do it
explicitly and actually write the code that way?  What is
the advantage in putting this in the core and having it
happen magically and behind the scenes, as it appears you
want to happen?


More information about the Python-list mailing list