Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: "Frank Millman" Newsgroups: comp.lang.python Subject: Re: (Python 3.5) Asyncio and an attempt to run loop.run_until_complete() from within a running loop Date: Sat, 9 Apr 2016 07:08:52 +0200 Lines: 20 Message-ID: References: <33e44698-2625-47c4-9595-00a8c79f27ad@googlegroups.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 KrAvg4X6Yr6OHuDIK14p6wA9y1ypiQf7JbmKdK9HWYqg== 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; 'subject:Python': 0.05; '"if': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'coroutines': 0.16; 'expert,': 0.16; 'help?': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'subject:run': 0.16; 'task.': 0.16; 'skip:l 30': 0.18; 'skip:n 60': 0.22; 'wrote': 0.23; 'attach': 0.23; 'header:In-Reply-To:1': 0.24; 'header:X-Complaints-To:1': 0.26; 'handling': 0.27; 'subject:) ': 0.32; 'run': 0.33; 'facility': 0.33; 'advice': 0.35; 'something': 0.35; 'but': 0.36; 'there': 0.36; 'to:addr:python-list': 0.36; 'received:org': 0.37; 'wanted': 0.37; 'does': 0.39; 'subject:from': 0.39; 'to:addr:python.org': 0.40; 'future': 0.60; 'back': 0.62; 'frank': 0.72; 'task,': 0.91 X-Injected-Via-Gmane: http://gmane.org/ X-Gmane-NNTP-Posting-Host: 197.86.206.120 In-Reply-To: <33e44698-2625-47c4-9595-00a8c79f27ad@googlegroups.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.21 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: X-Mailman-Original-References: <33e44698-2625-47c4-9595-00a8c79f27ad@googlegroups.com> Xref: csiph.com comp.lang.python:106721 "Alexander Myodov" wrote in message news:33e44698-2625-47c4-9595-00a8c79f27ad@googlegroups.com... > Hello. > TLDR: how can I use something like loop.run_until_complete(coro), to > execute a coroutine synchronously, while the loop is already running? I am no expert, but does this help? "If you're handling coroutines there is an asyncio facility for "background tasks". asyncio.ensure_future() will take a coroutine, attach it to a Task, and return a future to you that resolves when the coroutine is complete." This advice was given to me a while back when I wanted to run a background task. It works perfectly for me. Frank Millman