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


Groups > comp.lang.python > #102200

Re: Question about asyncio and blocking operations

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Ian Kelly <ian.g.kelly@gmail.com>
Newsgroups comp.lang.python
Subject Re: Question about asyncio and blocking operations
Date Thu, 28 Jan 2016 17:20:50 -0700
Lines 15
Message-ID <mailman.67.1454026859.2338.python-list@python.org> (permalink)
References <n8038j$575$1@ger.gmane.org> <n8818q$35e$1@ger.gmane.org> <CALwzidk-RBkB-vi6CgcEeoFHQrsoTFvqX9MqzDD=rnY5bOCRUg@mail.gmail.com> <n8aln3$fah$1@ger.gmane.org> <CALwzidn6TvN9W-2qnn2JYvJu8NHzn499nPtfjn9OHjdDcebVbA@mail.gmail.com> <CALwzidmmUeL3Sq9o6ZgKYM3-V22HCshG03wQqsXvhh6xy1otgQ@mail.gmail.com> <CALwzidkr-fT6S6wH2caNaxyQvUdAw=x7XDqkqOfNRrwzwnjvOQ@mail.gmail.com> <n8cm4k$ojk$1@ger.gmane.org> <CAPTjJmr162+K4LZeFpXruR6wxrHxbR-_wkrCLLDyR7kST+kjYg@mail.gmail.com> <n8ct18$fu4$1@ger.gmane.org> <CALwzidnGbz7kM=D7MKua2tA9-csFn9u0OHL0w-X5Bbixpcw4Ow@mail.gmail.com> <n8dgas$s1u$1@ger.gmane.org> <CALwzidn6NfT_O0cfHw1itWja81+MW3scHuEcADVCen3ix6z73w@mail.gmail.com> <CAGqiJR-kbF2HDTPRG=49yEDkyZZRQbUC-=3Dq_bApab2exsKAw@mail.gmail.com> <CALwzidm49eYvx6E2fW0MXHmqZkQ0z40hSWwcH8J259sZuKthfQ@mail.gmail.com> <CAGqiJR9ZyfND2O89mHX3u8TztRNjZDYPkQVV_Z_VGSsMFxDZ9w@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
X-Trace news.uni-berlin.de 622tpXP8WWs0+ixhmEVOfAldfAD0e+MALtsUEYE5p1Iw==
Return-Path <ian.g.kelly@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'received:209.85.223': 0.03; 'subject:Question': 0.05; 'concurrently': 0.07; 'wrapper': 0.07; 'cursor': 0.09; 'loop.': 0.09; 'rows': 0.09; 'assume': 0.11; 'jan': 0.11; '2016': 0.16; 'involved;': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'threads': 0.16; 'wrote:': 0.16; '&lt;': 0.18; 'pointed': 0.18; '&gt;': 0.18; 'email addr:gmail.com&gt;': 0.18; "aren't": 0.22; 'pass': 0.22; 'header:In-Reply-To:1': 0.24; 'separate': 0.27; 'message-id:@mail.gmail.com': 0.27; 'idea': 0.28; 'certain': 0.31; 'lock': 0.33; 'received:google.com': 0.35; 'could': 0.35; 'but': 0.36; 'received:209.85': 0.36; 'to:addr :python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'two': 0.37; 'agree': 0.37; 'method': 0.37; 'received:209': 0.38; 'to:addr:python.org': 0.40; "you'll": 0.61; 'strange': 0.63; 'obvious': 0.76; 'attractive': 0.79; 'each,': 0.84; 'isolate': 0.84; 'isolated': 0.84; 'to:name:python': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=1sGFRZe3qqIvxVNErzzJ81ESg8dGwXbwNM14IHMng9s=; b=L2Si7ddVoSiqJRQV2zSDMSOmcqxf37y3nSXCpya64AmfIeEO+JVteBclPr81w/1DPj Z/MC3236kbqcEWb5sIfC9O1reAm1CmUhTCRuWgcNAf988TwA8FN5LDIlNt3WD9ksKN5x kp4wcxFejTVESOcKmn2KdHk5vkXimMLXlGOc00OeFWaqO19pzxvWj1kQY5hEGXg4ifmv 9jGLvpHqYM+u1AAdpEIfbZBIf2/O2Vpvy+UMY2TqHNzYOm9tgz2nf2ne8MZd4+oOood/ pAtzKZRE3QRZFCjdRh9CCATWje/hoEDaASkYs76KuLxPvzPC+/YIcDDzJyARoCoY5bRA PqCA==
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=1sGFRZe3qqIvxVNErzzJ81ESg8dGwXbwNM14IHMng9s=; b=NeEYMUzBW8sCqAkYX0RpU+ahxXGV087mQ5UcIIS4XdVqukbDc58C4DdHAZUAm8GXu1 hrw33lFDJj4vDGTLx3a6UALupIcEFWYsty6xYSUMMJjLro+GJArti2WUOzvtA2/IzNV7 D18w4HVowJWsy8Wd5J89L5ToSkWMuWgUrJU4jVtQv1L7TbE4IUZPoSByjIhiVkwafIu3 l3jbum9hPv9/NsIHMWJumSWLGxcpWcBN0RnPcW39xSTJDhNotWl+pGmrP+JBGuHfZYuA 3RVSRlt1cLWdDJ1DagdQI1ipO5lsBXEdYzSxx/jucmTuBGXC9VyLIAAOoiqKPqItGDYL Qzuw==
X-Gm-Message-State AG10YORJH/yaZZxdaSh0DmBvf/Lxi7XyugsmiABeSFNz2khx6UrMJBCZiNR7P8J1KKvjcJPaj/78Xbjp+pdjxg==
X-Received by 10.107.185.6 with SMTP id j6mr7177522iof.111.1454026850877; Thu, 28 Jan 2016 16:20:50 -0800 (PST)
In-Reply-To <CAGqiJR9ZyfND2O89mHX3u8TztRNjZDYPkQVV_Z_VGSsMFxDZ9w@mail.gmail.com>
X-Content-Filtered-By Mailman/MimeDel 2.1.20+
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:102200

Show key headers only | View raw


On Jan 28, 2016 3:07 PM, "Maxime Steisel" <maximesteisel@gmail.com> wrote:
>
> But it is a pretty strange idea to call two fetch*() method concurrently
anyways.

If you want to process rows concurrently and aren't concerned with
processing them in order, it may be attractive to create multiple threads /
coroutines, pass the cursor to each, and let them each call fetchmany
independently. I agree this is a bad idea unless you use a lock to isolate
the calls or are certain that you'll never use a dbapi implementation with
threadsafety < 3.

I pointed it out because the wrapper makes it less obvious that multiple
threads are involved; one could naively assume that the separate calls are
isolated by the event loop.

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


Thread

Re: Question about asyncio and blocking operations Ian Kelly <ian.g.kelly@gmail.com> - 2016-01-28 17:20 -0700

csiph-web