Path: csiph.com!feeder.erje.net!2.eu.feeder.erje.net!newsreader4.netcologne.de!news.netcologne.de!newsfeed0.kamp.net!newsfeed.kamp.net!fu-berlin.de!uni-berlin.de!not-for-mail From: "Joseph L. Casale" Newsgroups: comp.lang.python Subject: Re: Passing data across callbacks in ThreadPoolExecutor Date: Fri, 19 Feb 2016 17:18:55 +0000 Lines: 46 Message-ID: References: , Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Trace: news.uni-berlin.de 5EmP2vqiScDx1Mrjxqeb6AWFKNI1HKV36ymT6bWcowoQ== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.011 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; '"c"': 0.07; 'continuation': 0.07; '"a"': 0.09; 'callback': 0.09; 'tasks,': 0.09; 'def': 0.13; 'result.': 0.15; '"b"': 0.16; 'chained': 0.16; 'did.': 0.16; 'distinct': 0.16; 'failed.': 0.16; 'received:172.18.0': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'task.': 0.16; 'runs': 0.18; 'to:2**1': 0.21; 'do.': 0.22; 'complete,': 0.22; 'trying': 0.22; 'sets': 0.23; 'header:In-Reply- To:1': 0.24; "doesn't": 0.26; 'cancel': 0.27; 'specifically': 0.28; 'about.': 0.29; 'work.': 0.30; 'help!': 0.30; 'task': 0.30; 'another': 0.32; 'problem': 0.33; 'apply,': 0.33; 'previous': 0.34; 'clear': 0.35; 'set.': 0.35; 'tasks': 0.35; 'but': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'really': 0.37; 'thanks': 0.37; "didn't": 0.39; 'submit': 0.39; 'to:addr:python.org': 0.40; 'still': 0.40; 'future': 0.60; 'back': 0.62; 'more': 0.63; 'different': 0.63; 'detail.': 0.66; 'subject:skip:T 10': 0.66; 'future.': 0.67; 'completed': 0.69; 'completes': 0.84; 'to:name:python': 0.84; 'do:': 0.91 X-Authority-Analysis: v=2.1 cv=EvBy1XoA c=1 sm=1 tr=0 a=g3mLq75WYuDrh3Lt0JSDww==:117 a=g3mLq75WYuDrh3Lt0JSDww==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=P90J6pEA2ccA:10 a=8nJEP1OIZ-IA:10 a=jFJIQSaiL_oA:10 a=JyKPzex8cZwBDz0_IMAA:9 a=wPNLvfGTeEIA:10 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.activenetwerx.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,RP_MATCHES_RCVD autolearn=unavailable autolearn_force=no version=3.4.0 Thread-Topic: Passing data across callbacks in ThreadPoolExecutor Thread-Index: AQHRaQOLnYiuCC9hLkqY+oiLW/4uEJ8w4q2AgAFIQtCAAQV+gIAAbwpM In-Reply-To: Accept-Language: en-CA, en-US Content-Language: en-CA X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [172.18.0.4] X-CMAE-Envelope: MS4wfN3lFu1/PpTiHKUNQZqVfyTWLBM4aEOJXJgNwrxXUS6lLBvGnF6cVL7tLfnUN/NydK3nfSDKTZ8SjP7XcETJFTHBI4QMgyRAOks81UGWvYKdalkesCee bO/kk9vDkK3duSauNw7EfCqqjzRqfFrhMuJ0JiaZU/3vMTkyGFHUWdMTSG5lu092otZ0RrkVTUEUGQ== X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21rc2 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:103207 > It's still not clear to me specifically what you're trying to do. It > would really help if you would describe the problem in more detail. > Here's what I think you're trying to do: >=20 > 1) Submit a task to a ThreadPoolExecutor and get back a future. >=20 > 2) When the task is complete, submit another task that needs the > result of the first task to do its work. >=20 > 3) When the chained task is complete, return the final result of the > chained task back to whoever submitted the original task via the > original task's future. >=20 > The problem arises in that the original task's future already > completed when the original task did. The chained task sets its result > in a different future that the submitter didn't know about. Yes, I may have 2 or more tasks that depend on the previous. They are each distinct tasks, or continuations, so they each want the resul= t of the previous task however each one can cancel the set. The callback model doesn't apply, its based on the result of _one_ task. What I need I are continuations, much like the .NET TPL. def task_a(): return "a" def task_b(): return "b" def task_c(): return "c" So I submit task_a, if it completes successfully, task_b runs on its result= . If task_b completes successfully, task_c runs on its result. They "look" like callbacks, but they are continuations. Task_b must be able to cancel the continuation of task_c if it see's task_= a has failed. Thanks for the continued help! jlc=