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


Groups > comp.lang.python > #102210

Re: Question about asyncio and blocking operations

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From "Frank Millman" <frank@chagford.com>
Newsgroups comp.lang.python
Subject Re: Question about asyncio and blocking operations
Date Fri, 29 Jan 2016 07:23:21 +0200
Lines 22
Message-ID <mailman.75.1454045022.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>
Mime-Version 1.0
Content-Type text/plain; format=flowed; charset="iso-8859-1"; reply-type=original
Content-Transfer-Encoding 7bit
X-Trace news.uni-berlin.de oCBm80N8w/Rs3/e/AwiZRglqoZAAtqctBrNRrUZTDHeg==
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.005
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'retrieved': 0.05; 'subject:Question': 0.05; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'rows': 0.09; 'thread': 0.10; 'commented': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'skip:n 70': 0.16; 'stimulating': 0.16; 'seems': 0.23; 'wrote': 0.23; 'header:In-Reply-To:1': 0.24; 'header:X-Complaints-To:1': 0.26; 'comfortable': 0.27; 'skip:e 30': 0.27; 'clever': 0.29; 'there.': 0.30; 'getting': 0.33; 'run': 0.33; 'previous': 0.34; 'could': 0.35; 'done': 0.35; 'something': 0.35; 'there': 0.36; 'to:addr :python-list': 0.36; 'subject:: ': 0.37; 'thanks': 0.37; 'received:org': 0.37; 'to:addr:python.org': 0.40; 'some': 0.40; 'behavior': 0.61; 'strange': 0.63; 'here': 0.66; 'results.': 0.67; 'frank': 0.72; 'difference.': 0.84; 'instantly.': 0.91
X-Injected-Via-Gmane http://gmane.org/
X-Gmane-NNTP-Posting-Host 197.89.197.37
In-Reply-To <CALwzidn6NfT_O0cfHw1itWja81+MW3scHuEcADVCen3ix6z73w@mail.gmail.com>
X-MSMail-Priority Normal
Importance Normal
X-Newsreader Microsoft Windows Live Mail 15.4.3502.922
X-MimeOLE Produced By Microsoft MimeOLE V15.4.3502.922
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:102210

Show key headers only | View raw


"Ian Kelly"  wrote in message 
news:CALwzidn6NfT_O0cfHw1itWja81+MW3scHuEcADVCen3ix6z73w@mail.gmail.com...
>
> As I commented in my previous message, asyncio.Queue is not
> thread-safe, so it's very important that the put calls here be done on
> the event loop thread using event_loop.call_soon_threadsafe. This
> could be the cause of the strange behavior you're seeing in getting
> the results.
>

Using call_soon_threadsafe makes all the difference. The rows are now 
retrieved instantly.

I have read the other messages, and I can see that there are some clever 
ideas there. However, having found something that seems to work and that I 
feel comfortable with, I plan to run with this for the time being.

Thanks to all for the very stimulating discussion.

Frank

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


Thread

Re: Question about asyncio and blocking operations "Frank Millman" <frank@chagford.com> - 2016-01-29 07:23 +0200

csiph-web