Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Ian Kelly Newsgroups: comp.lang.python Subject: Re: Bi-directional sub-process communication Date: Tue, 24 Nov 2015 14:53:17 -0700 Lines: 14 Message-ID: References: <84B23819-6214-4BDA-959D-85CD46431212@ravnalaska.net> <20151124052512.GA51713@cskk.homeip.net> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de A3dNIWmAvQc8hdW9DYahggSg+Zsp+MXdDjCQTc6+lf+A== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'handler': 0.04; 'caller': 0.07; 'subject:skip:c 10': 0.07; 'attribute.': 0.09; 'subject:process': 0.09; '23,': 0.16; 'allocates': 0.16; 'collects': 0.16; 'fires': 0.16; 'obviously,': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'simpson': 0.16; 'subject:sub': 0.16; 'subprocess,': 0.16; 'wait.': 0.16; 'wrote:': 0.16; 'attribute': 0.18; ';-)': 0.18; '2015': 0.20; '(by': 0.22; 'sets': 0.23; 'header:In-Reply-To:1': 0.24; 'mon,': 0.24; "i've": 0.25; 'message-id:@mail.gmail.com': 0.27; 'information;': 0.29; 'class': 0.33; 'common': 0.33; 'gets': 0.35; 'received:google.com': 0.35; 'instance': 0.35; 'nov': 0.35; 'something': 0.35; 'submitting': 0.35; 'but': 0.36; 'received:209.85': 0.36; 'data.': 0.36; 'event.': 0.36; 'to:addr :python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'method': 0.37; 'received:209.85.213': 0.37; 'received:209': 0.38; 'does': 0.39; 'subject:-': 0.39; 'to:addr:python.org': 0.40; 'called': 0.40; 'waiting': 0.60; 'your': 0.60; 'cameron': 0.66; 'future.': 0.67; 'receive': 0.71; 'sounds': 0.76; 'to:name:python': 0.84; 'wakes': 0.84 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:to :content-type; bh=s+z5A4dWURFM9ifxrakHSi5Nx18C7Nv/BHQGIsFAjVA=; b=IXEcc8rOFE4HLamo1yV/LL2CiGcpILMA76r85zM7F3Ut8lQ0cuWnBV46BV+wnv/vdJ 2+gYTxtK557wpJOnSewdgW9+HXldgcYTBs0ibnf7q4kwaAsZQRqcCHf482I9akR7HAR1 e9E7FI4O1tG6CjBYhO9VJPrVSet6vqFFoChFHfBYbAZpzZ7Ew3pnPVJxQsSwgnE3JFFP oRZuPwm3ThlD78wBA75TyO6W18Cy0WgVexPFuOKJ9x8BScLD+KsaRq5h37jS62stk8Nq GatHeQZfcmiQeyLEjc4c0ARBl8BD9OEY6EJ2hsBtI8g9aP0Ad202t0b4k17D85Mux4Ji nsFA== X-Received: by 10.50.12.42 with SMTP id v10mr730938igb.85.1448402036967; Tue, 24 Nov 2015 13:53:56 -0800 (PST) In-Reply-To: <20151124052512.GA51713@cskk.homeip.net> 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:99400 On Mon, Nov 23, 2015 at 10:25 PM, Cameron Simpson wrote: > Then #3. I would have a common function/method for submitting a request to > go to the subprocess, and have that method return an Event on which to wait. > Then caller then just waits for the Event and collects the data. Obviously, > the method does not just return the Event, but an Event and something to > receive the return data. I've got a class called a Result for this kind of > thing; make a small class containing an Event and which will have a .result > attribute for the return information; the submitting method allocates one of > these and returns it. The response handler gets the instance (by looking it > up from the tag), sets the .result attribute and fires the Event. Your > caller wakes up from waiting on the Event and consults the .result > attribute. Your Result sounds suspiciously like a Future. ;-)