On 18/05/2011 03:10, Terry Reedy wrote:
By default, Python iterators operate in pull mode -- consumers request a
new item when they want one. I believe .send was mostly intended to
reverse that, to operate in push mode where producers .send() a item to
a consumer when they are ready to. That is
Hi All,
I'm looking for a graceful pattern for the situation where I have a
provider of a sequence, the consumer of a sequence and code to moderate
the two, and where I'd like to consumer to be able to signal to the
provider that it hasn't succeeded in processing one element in the queue.
On Tue, May 17, 2011 at 11:04 AM, Chris Withers ch...@simplistix.co.uk wrote:
Now, since the sequence is long, and comes from a file, I wanted the
provider to be an iterator, so it occurred to me I could try and use the new
2-way generator communication to solve the communicate back with the
On Tuesday, May 17, 2011 10:04:25 AM UTC-7, Chris Withers wrote:
Now, since the sequence is long, and comes from a file, I wanted the
provider to be an iterator, so it occurred to me I could try and use the
new 2-way generator communication to solve the communicate back with
the provider,
On 5/17/2011 1:04 PM, Chris Withers wrote:
Hi All,
I'm looking for a graceful pattern for the situation where I have a
provider of a sequence, the consumer of a sequence and code to moderate
the two, and where I'd like to consumer to be able to signal to the
provider that it hasn't succeeded in
On Wed, May 18, 2011 at 3:04 AM, Chris Withers ch...@simplistix.co.uk wrote:
Hi All,
I'm looking for a graceful pattern for the situation where I have a provider
of a sequence, the consumer of a sequence and code to moderate the two, and
where I'd like to consumer to be able to signal to the
On 17/05/2011 18:26, Ian Kelly wrote:
You can use send the way you're wanting to. It will look something like this:
def provider():
result = None
while True:
if result is None:
if has_more_items():
next_item = get_next_item()
else:
break
elif
On Tue, May 17, 2011 at 11:27 PM, Chris Withers ch...@simplistix.co.uk wrote:
Yes, but it's this kind of birds nest I'm trying to avoid...
I was actually kind of hoping you might see it that way. That's about
as simple as you're going to get using a generator for this, though.
I'll second