Re[4]: Re: New stackless proposal

Lenard Lindstrom <[email protected]>
Newsgroups gmane.comp.lang.prothon.user
Message-ID <Mahogany-0.66.0-4294700835-20040712-132232.00@pop3.norton.antivirus>
On Sun, 11 Jul 2004 22:17:50 -0700 Mark Hahn <[email protected]> wrote:

> Lenard Lindstrom wrote:
> 
> > The question is whether or not prothon threads will be preemptive at
> > the byte code level? I do not know if this is the case for Stackless
> > tasklets so assumed they were. If the generator lacks a yield -
> > entirely possible - or fails to call it the thread calling the
> > generator may call its yield before the generator has completed. So
> > the calling thread will wait indefinitely.
> 
> Even if the calling thread has already hit its yield it can still get an
> exception and leave the yield.  There is no difference before and after
> getting to the yield.  You are saying there is a race but you are wrong.
> 
> > If the first StopIteration
> > is handled using yield then the calling thread is guaranteed to
> > return.
> 
> I don't understand what situation could cause the calling thread to not
> return.  Ultimately the generator thread must hit a yield or terminate.  So
> it will either yield a value or cause an exception.  There is no third
> possibility.
> 
So a terminating thread will raise an exception on all threads waiting on it?

def genfun():
    sleep(1.0)  # A very intensive computation
    # Return without calling yield
generator = Thread(genfun)

iter = generator().iter_()  # Generator goes to sleep
iter.next()                 # Now yielding to sleeping generator thread. Will I hang?

Lenard Lindstrom
<[email protected]>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.