Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Ian Kelly 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: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de 622tpXP8WWs0+ixhmEVOfAldfAD0e+MALtsUEYE5p1Iw== Return-Path: 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; '<': 0.18; 'pointed': 0.18; '>': 0.18; 'email addr:gmail.com>': 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: 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:102200 On Jan 28, 2016 3:07 PM, "Maxime Steisel" 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.