[Python-ideas] .then execution of actions following a future's completion

Daniel Collins dancollins34 at gmail.com
Fri Jan 26 11:58:01 EST 2018


Yeah, it would be better to use the chain_future call from async directly, but the problems are 1) it would make concurrent dependent on async and 2) if it were public, it would require users to instantiate futures, which they’re not supposed to do.

-dancollins34

Sent from my iPhone

> On Jan 26, 2018, at 3:16 AM, Bar Harel <bzvi7919 at gmail.com> wrote:
> 
> I have a simple way to solve this I believe.
> 
> Why not just expose "_chain_future()" from asyncio/futures.py to the public, instead of copying and pasting parts of it?
> 
> It already works, being used everywhere in the stdlib, it supports both asyncio and concurrent.futures, it's an easily testable external function (follows the design of asyncio for the better part), it's threadsafe right out of the box and it wouldn't require anything but removing a single underscore and adding documentation. (I always wondered why was it private anyway)
> 
> It's like the function was meant to be public :-P
> 
> -- Bar
> 
> 
>> On Fri, Jan 26, 2018, 8:07 AM Guido van Rossum <guido at python.org> wrote:
>> I really don't want to distract Yury with this. Let's consider this (or something that addresses the same need) for 3.8.
>> 
>> To be clear this is meant as a feature for concurrent.futures.Future, not for asyncio.Future. (It's a bit confusing since you also change asyncio.)
>> 
>> Also to be honest I don't understand the use case *or* the semantics very well. You have some explaining to do...
>> 
>> (Also, full links: https://bugs.python.org/issue32672; https://github.com/python/cpython/pull/5335)
>> 
>>> On Thu, Jan 25, 2018 at 8:38 PM, Daniel Collins <dancollins34 at gmail.com> wrote:
>>> Hello all,
>>> 
>>> So, first time posting here. I’ve been bothered for a while about the lack of the ability to chain futures in python, such that the next future will execute upon the first’s completion.  So I submitted a pr to do this.  This would add the .then(self, fn) method to concurrent.futures.Future.  Thoughts?
>>> 
>>> -dancollins34
>>> 
>>> Github PR #5335
>>> bugs.python.org issue #32672
>>> 
>>> _______________________________________________
>>> Python-ideas mailing list
>>> Python-ideas at python.org
>>> https://mail.python.org/mailman/listinfo/python-ideas
>>> Code of Conduct: http://python.org/psf/codeofconduct/
>>> 
>> 
>> 
>> 
>> -- 
>> --Guido van Rossum (python.org/~guido)
>> _______________________________________________
>> Python-ideas mailing list
>> Python-ideas at python.org
>> https://mail.python.org/mailman/listinfo/python-ideas
>> Code of Conduct: http://python.org/psf/codeofconduct/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180126/8f1c6cad/attachment-0001.html>


More information about the Python-ideas mailing list