Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Zachary Ware Newsgroups: comp.lang.python Subject: Re: Futex hang when running event loop on a separated thread Date: Tue, 24 Nov 2015 12:11:10 -0600 Lines: 18 Sender: zachary.ware@gmail.com Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de JBmt1klBY5Wzp04yu48BuQQXMgBwpHSqP43ygqAWI2kw== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'handler': 0.04; 'finally:': 0.05; '__name__': 0.07; 'cc:addr:python-list': 0.09; 'loop.': 0.09; 'received:209.85.218': 0.10; 'thread': 0.10; "'__main__':": 0.16; '24,': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:when': 0.16; 'wrote:': 0.16; 'sender:addr:gmail.com': 0.18; 'try:': 0.18; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'am,': 0.23; 'header :In-Reply-To:1': 0.24; 'message-id:@mail.gmail.com': 0.27; 'marc': 0.29; 'tue,': 0.34; 'running': 0.34; 'received:google.com': 0.35; 'nov': 0.35; 'received:209.85': 0.36; 'subject:: ': 0.37; 'doing': 0.38; 'received:209': 0.38; 'called': 0.40; 'hope': 0.61 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=+WmhvXV0jI/YHdUT8vCuMzPdTIzeMPBt3C4iblrGGq8=; b=vrN52bjiCePaamCGirNrkg9MxLvawF0qNKqNvN3UAaOt7xCvIA3UTLs1/iXKjpncF2 ghtGaHXiUeQTPY0XLbIrFg3kf+QVBqjgWNE93nHHYsN1iOPLRSh6GEGNaRRPMImEbTrC 9awnsCWNnibsCUILLNxZofCOwCvSwfIWiTOLQLJKWeKHt+xvnStwt93XVT3KPOxpBQ7N lcsvf8ZZ02HX+5LOk5b8uTO0VFvz2xprFj73ApD5qjH/avNHXp3oDfzyr1ZFBuSQLMNW PM4yGhlNTbh1V5BLI1iwZn9QZ39ZD5fWlpZSNvIB5MHNf+o9IgLL9D0fpv+R4h60zcuM yh3g== X-Received: by 10.202.230.17 with SMTP id d17mr10627416oih.60.1448388689550; Tue, 24 Nov 2015 10:11:29 -0800 (PST) In-Reply-To: X-Google-Sender-Auth: foqb_FwudwVUSkY1YueBUCbEvCc 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:99380 On Tue, Nov 24, 2015 at 9:46 AM, Marc Aymerich wrote: > if __name__ == '__main__': > loop_container = {} > handler = threading.Thread(target=run_loop, args=(loop_container, )) > handler.start() > try: > time.sleep(10000) > finally: > loop_container['loop'].stop() loop.stop() must be called from the thread running the loop. You can do this by doing `loop_container['loop'].call_soon_threadsafe(loop_container['loop'].stop)` from the main thread (untested). Hope this helps, -- Zach