Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: "Frank Millman" 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: References: 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: 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: 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:102210 "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