This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author josh.r
Recipients cool-RR, josh.r, sbt
Date 2014-07-04.00:29:56
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1404433798.23.0.018575577269.issue18212@psf.upfronthosting.co.za>
In-reply-to
Content
Have an idea for a name? It already has a done method, which happens to cover the case of a Future having completed successfully, completed due to an exception or having been cancelled. Simply calling it "finished()", "completed()" etc. isn't markedly different from "done()".

Exposing it as a property would be a bad idea largely because it would be inconsistent with the rest of the Future interface that is purely method based (I suspect largely because some of the behaviors must be method based to allow arguments related to timeout and they just kept up the pattern).

The main argument I can see *against* making this easier than Richard's 2-3 part check (beyond the naming issue) is that it tends to encourage misuse of the library. Polling your Futures is a bad design 99% of the time (the same way loops over range(len(someseq)) are a bad idea most of the time; it's not that it doesn't work, it's that it's a backwards way to do it). In general:

1. If you need a single result now, you use future.result() directly
2. If you need to wait for a set of things to complete, you use:
  a. concurrent.futures.wait if you need all of them to finish before continuing
  b. concurrent.futures.as_completed if you can process them as they become available
3. If you don't have a loop processing worker results, but want the values to be used as they become available, you use future.add_done_callback() and let the result get processed asynchronously without your main thread becoming involved at all

Note: None of these cases really benefit from the existing status check methods. Instantaneous state checks are generally frowned upon in concurrent code, since program behavior can hinge on a microsecond race between the task and the checking thread, so polling is almost always worse than one of the more "event driven" approaches. I'm open to argument (I'm not omniscient), but I see this as making it even easier to do threading, rather than a legitimate improvement.
History
Date User Action Args
2014-07-04 00:29:58josh.rsetrecipients: + josh.r, cool-RR, sbt
2014-07-04 00:29:58josh.rsetmessageid: <1404433798.23.0.018575577269.issue18212@psf.upfronthosting.co.za>
2014-07-04 00:29:58josh.rlinkissue18212 messages
2014-07-04 00:29:56josh.rcreate