Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Marc Aymerich Newsgroups: comp.lang.python Subject: Re: Futex hang when running event loop on a separated thread Date: Tue, 24 Nov 2015 19:37:35 +0100 Lines: 29 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de aeNFI9Ukm8SfAOr6TpSJsgVCciCECXNplAJQjnEtjqgQ== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'handler': 0.04; 'finally:': 0.05; '__name__': 0.07; 'differently': 0.07; 'cc:addr :python-list': 0.09; 'loop.': 0.09; 'thread': 0.10; "'__main__':": 0.16; '24,': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'stuff,': 0.16; 'subject:when': 0.16; 'wrote:': 0.16; 'try:': 0.18; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'am,': 0.23; 'appears': 0.23; 'header:In-Reply-To:1': 0.24; 'message-id:@mail.gmail.com': 0.27; 'idea': 0.28; 'marc': 0.29; 'maybe': 0.33; "skip:' 20": 0.34; 'tue,': 0.34; 'running': 0.34; 'received:google.com': 0.35; 'nov': 0.35; 'but': 0.36; 'received:209.85': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'received:209.85.213': 0.37; 'doing': 0.38; 'received:209': 0.38; 'why': 0.39; 'still': 0.40; 'called': 0.40; 'waiting': 0.60; 'confirm': 0.62; 'to:none': 0.91; 'ware': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:cc :content-type; bh=oZdyKBX62CNSQ5a76bWVM4+2hvbSh9ff28gia4rb48w=; b=tjAzhbpTGNY22HNT1Bfpz8oz4k3II6v7uSYPUgB6SM32ite5YiunEfMd5sjJBszQ76 GfEYn+7knXT/hvb5HkSPFu83u6jSfb/BHgy0msRano1EIqXw/a15v0fddX1qjtWK0oBc b+A5Q0WPB3xXsxbLK5g6xPCXGej/08iwi/nEW6QoQ15sTXNK793v7+NiMQgigbtMCgLW ew1a/p1KUk03Ik8rQkVOIbbo1aw49CPUDsfk3Jj7tB/GYpV5Mav0uBXq1pw2x5S/ofV7 sZTRqVeOnZW/ZNz8Dmrl3s98557EpPhjt1nntn3j9OMDxo930bBGWQJAiwC2seS6jJne DDsw== X-Received: by 10.50.66.144 with SMTP id f16mr12019107igt.22.1448390274467; Tue, 24 Nov 2015 10:37:54 -0800 (PST) In-Reply-To: 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:99384 On Tue, Nov 24, 2015 at 7:11 PM, Zachary Ware wrote: > 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). > Hi Zachary, nice to know about call_soon_threadsafe! still it appears to work only if the main thread is in the foreground (as of calling Thread() with deamon=True), I don't get why it behaves differently :( maybe it is waiting for other stuff, but no idea how to confirm this with strace of other means.. i always see the same 'futex(0x7f9a70000c10, FUTEX_WAIT_PRIVATE, 0, NULL' -- Marc