Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #102299

Re: Cannot step through asynchronous iterator manually

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From "Frank Millman" <frank@chagford.com>
Newsgroups comp.lang.python
Subject Re: Cannot step through asynchronous iterator manually
Date Sat, 30 Jan 2016 14:39:44 +0200
Lines 31
Message-ID <mailman.125.1454157753.2338.python-list@python.org> (permalink)
References <n8hjmt$b8n$1@ger.gmane.org> <CALwzid=sSDSm8hdAN+ORJ54A_jEu9Wc8103iqGKAah8mrj-TXw@mail.gmail.com> <n8hrs1$orn$1@ger.gmane.org> <CAPTjJmoAmVNTCKq7QYaDRNQ67Gcg9TxSXYXCrY==S9Djjna_rA@mail.gmail.com> <n8i4j9$lb4$1@ger.gmane.org> <CAGqiJR8yUdd1u7j0YHS-He_v4uUT-ui=PpiX=n_G=ntt8ZnTpg@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; format=flowed; charset="iso-8859-1"; reply-type=original
Content-Transfer-Encoding 7bit
X-Trace news.uni-berlin.de Gvntpa08ZDwMzFFmbnNEBApSvukvuj061G8QH0iw/otw==
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; '-1.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; ':-)': 0.12; 'def': 0.13; 'async': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'row': 0.16; 'select.': 0.16; 'skip:n 70': 0.16; 'sqlite3': 0.16; 'thanks.': 0.18; 'bit': 0.23; 'wrote': 0.23; 'tried': 0.24; 'header:In-Reply-To:1': 0.24; 'header:X -Complaints-To:1': 0.26; 'solution,': 0.29; 'raise': 0.29; 'something': 0.35; 'but': 0.36; 'skip:i 20': 0.36; 'to:addr :python-list': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'why': 0.39; 'to:addr:python.org': 0.40; 'skip:n 10': 0.62; 'needing': 0.63; 'choose': 0.68; 'frank': 0.72
X-Injected-Via-Gmane http://gmane.org/
X-Gmane-NNTP-Posting-Host 197.86.205.12
In-Reply-To <CAGqiJR8yUdd1u7j0YHS-He_v4uUT-ui=PpiX=n_G=ntt8ZnTpg@mail.gmail.com>
X-MSMail-Priority Normal
Importance Normal
X-Newsreader Microsoft Windows Live Mail 15.4.3502.922
X-MimeOLE Produced By Microsoft MimeOLE V15.4.3502.922
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Xref csiph.com comp.lang.python:102299

Show key headers only | View raw


"Maxime S"  wrote in message 
news:CAGqiJR8yUdd1u7j0YHS-He_v4uUT-ui=PpiX=n_G=ntt8ZnTpg@mail.gmail.com...

>
> I might be a bit off-topic, but why don't you simply use cursor.rowcount?
>

I just tried that on sqlite3 and pyodbc, and they both return -1.

I think that it only works with insert/update/delete, but not with select.

> For a pure iterator-based solution, I would do something like this 
> (admitly
> a bit cryptic, but iterator-based solutions often are :-) :
>
> async def get_uniqu(ait):
>     async for row in ait:
>         break
>     else:
>         raise NotEnoughtRows()
>     async for _ in ait:
>         raise TooManyRows()
>     return row
>

Also nice - thanks. I now have a few to choose from without needing an 
'anext()'.

Frank

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Cannot step through asynchronous iterator manually "Frank Millman" <frank@chagford.com> - 2016-01-30 14:39 +0200

csiph-web