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


Groups > comp.lang.python > #102299

Re: Cannot step through asynchronous iterator manually

From "Frank Millman" <frank@chagford.com>
Newsgroups comp.lang.python
Subject Re: Cannot step through asynchronous iterator manually
Date 2016-01-30 14:39 +0200
Message-ID <mailman.125.1454157753.2338.python-list@python.org> (permalink)
References (1 earlier) <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>

Show all headers | 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