Re: Thread vs. generator problem

2006-05-26 Thread Paul Rubin
"Tim Peters" <[EMAIL PROTECTED]> writes: > > g = remote_iterate(itertools.count) > > You didn't run this code, right? itertools.count() was intended. Sorry, I made a cut-and-paste error posting the message. My test case did use itertools.count(). > In any case, as when calling any generato

Re: Thread vs. generator problem

2006-05-26 Thread Tim Peters
[Paul Rubin] > ... > When I try to do it in a separate thread: > > import time, itertools > def remote_iterate(iterator, cachesize=5): > # run iterator in a separate thread and yield its values > q = Queue.Queue(cachesize) > def f(): > print 'thread start

Re: Thread vs. generator problem

2006-05-26 Thread Robert Kern
Paul Rubin wrote: > As I understand it, generators are supposed to run til they hit a > yield statement: > >import time >def f(): > print 1 > time.sleep(3) > for i in range(2,5): > yield i > >for k in f(): > print k > > prints "1" immediately, sleeps for