Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #102304
| From | "Frank Millman" <frank@chagford.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Cannot step through asynchronous iterator manually |
| Date | 2016-01-30 15:45 +0200 |
| Message-ID | <mailman.130.1454161573.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> <CAHVvXxSA0Yq4VOYy6qycgXxVpL5zZGM8muUi+1VmeZD8CRgtvg@mail.gmail.com> |
"Oscar Benjamin" wrote in message news:CAHVvXxSA0Yq4VOYy6qycgXxVpL5zZGM8muUi+1VmeZD8CRgtvg@mail.gmail.com... > > The simplest thing would just be to call list(cur) but I realise that you don't want to consume more than 2 rows from the database so just use islice: > > rows = list(islice(cur, 2)) # pull at most 2 rows > if not rows: > # no rows > elif len(rows) > 1: > # too many rows > row = rows[0] > I like the idea, but I don't think it would work with an asychronous iterable. OTOH it should not be difficult to roll your own using the example in the itertools docs as a base. Except that the example uses next(it) internally, and this thread started with the fact that there is no asychronous equivalent, so I might be back to square one. But these are all variations on a similar theme, so I don't think it matters which one I choose. I will go through them at my leisure and pick the most readable one. Thanks Frank
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Cannot step through asynchronous iterator manually "Frank Millman" <frank@chagford.com> - 2016-01-30 15:45 +0200
csiph-web