Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #102198 > unrolled thread
| Started by | Ian Kelly <ian.g.kelly@gmail.com> |
|---|---|
| First post | 2016-01-28 14:49 -0700 |
| Last post | 2016-01-28 14:49 -0700 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Question about asyncio and blocking operations Ian Kelly <ian.g.kelly@gmail.com> - 2016-01-28 14:49 -0700
| From | Ian Kelly <ian.g.kelly@gmail.com> |
|---|---|
| Date | 2016-01-28 14:49 -0700 |
| Subject | Re: Question about asyncio and blocking operations |
| Message-ID | <mailman.66.1454017808.2338.python-list@python.org> |
On Thu, Jan 28, 2016 at 2:23 PM, Maxime S <maxischmeii@gmail.com> wrote: > > 2016-01-28 17:53 GMT+01:00 Ian Kelly <ian.g.kelly@gmail.com>: >> >> On Thu, Jan 28, 2016 at 9:40 AM, Frank Millman <frank@chagford.com> wrote: >> >> > The caller requests some data from the database like this. >> > >> > return_queue = asyncio.Queue() >> > sql = 'SELECT ...' >> > request_queue.put((return_queue, sql)) >> >> Note that since this is a queue.Queue, the put call has the potential >> to block your entire event loop. >> > > Actually, I don't think you actually need an asyncio.Queue. > > You could use a simple deque as a buffer, and call fetchmany() when it is > empty, like that (untested): True. The asyncio Queue is really just a wrapper around a deque with an interface designed for use with the producer-consumer pattern. If the producer isn't a coroutine then it may not be appropriate. This seems like a nice suggestion. Caution is advised if multiple cursor methods are executed concurrently since they would be in different threads and the underlying cursor may not be thread-safe.
Back to top | Article view | comp.lang.python
csiph-web