@@ -194,15 +194,15 @@ def as_completed(fs, timeout=None):
194194 """An iterator over the given futures that yields each as it completes.
195195
196196 Args:
197- fs: The sequence of Futures (possibly created by different Executors) to
198- iterate over.
199- timeout: The maximum number of seconds to wait. If None, then there
200- is no limit on the wait time.
197+ fs: The sequence of Futures (possibly created by different
198+ Executors) to iterate over.
199+ timeout: The maximum number of seconds to wait. If None, then
200+ there is no limit on the wait time.
201201
202202 Returns:
203- An iterator that yields the given Futures as they complete (finished or
204- cancelled). If any given Futures are duplicated, they will be returned
205- once.
203+ An iterator that yields the given Futures as they complete
204+ (finished or cancelled). If any given Futures are duplicated,
205+ they will be returned once.
206206
207207 Raises:
208208 TimeoutError: If the entire result iterator could not be generated
@@ -258,19 +258,20 @@ def wait(fs, timeout=None, return_when=ALL_COMPLETED):
258258 """Wait for the futures in the given sequence to complete.
259259
260260 Args:
261- fs: The sequence of Futures (possibly created by different Executors) to
262- wait upon.
263- timeout: The maximum number of seconds to wait. If None, then there
264- is no limit on the wait time.
265- return_when: Indicates when this function should return. The options
266- are:
261+ fs: The sequence of Futures (possibly created by different
262+ Executors) to wait upon.
263+ timeout: The maximum number of seconds to wait. If None, then
264+ there is no limit on the wait time.
265+ return_when: Indicates when this function should return.
266+ The options are:
267267
268268 FIRST_COMPLETED - Return when any future finishes or is
269269 cancelled.
270270 FIRST_EXCEPTION - Return when any future finishes by raising an
271- exception. If no future raises an exception
271+ exception. If no future raises an exception
272272 then it is equivalent to ALL_COMPLETED.
273- ALL_COMPLETED - Return when all futures finish or are cancelled.
273+ ALL_COMPLETED - Return when all futures finish or are
274+ cancelled.
274275
275276 Returns:
276277 A named 2-tuple of sets. The first set, named 'done', contains the
@@ -404,11 +405,12 @@ def add_done_callback(self, fn):
404405
405406 Args:
406407 fn: A callable that will be called with this future as its only
407- argument when the future completes or is cancelled. The callable
408- will always be called by a thread in the same process in which
409- it was added. If the future has already completed or been
410- cancelled then the callable will be called immediately. These
411- callables are called in the order that they were added.
408+ argument when the future completes or is cancelled. The
409+ callable will always be called by a thread in the same
410+ process in which it was added. If the future has already
411+ completed or been cancelled then the callable will be
412+ called immediately. These callables are called in the
413+ order that they were added.
412414 """
413415 with self ._condition :
414416 if self ._state not in [CANCELLED , CANCELLED_AND_NOTIFIED , FINISHED ]:
@@ -423,17 +425,19 @@ def result(self, timeout=None):
423425 """Return the result of the call that the future represents.
424426
425427 Args:
426- timeout: The number of seconds to wait for the result if the future
427- isn't done. If None, then there is no limit on the wait time.
428+ timeout: The number of seconds to wait for the result if the
429+ future isn't done. If None, then there is no limit on the
430+ wait time.
428431
429432 Returns:
430433 The result of the call that the future represents.
431434
432435 Raises:
433436 CancelledError: If the future was cancelled.
434- TimeoutError: If the future didn't finish executing before the given
435- timeout.
436- Exception: If the call raised then that exception will be raised.
437+ TimeoutError: If the future didn't finish executing before the
438+ given timeout.
439+ Exception: If the call raised then that exception will be
440+ raised.
437441 """
438442 try :
439443 with self ._condition :
@@ -459,17 +463,17 @@ def exception(self, timeout=None):
459463
460464 Args:
461465 timeout: The number of seconds to wait for the exception if the
462- future isn't done. If None, then there is no limit on the wait
463- time.
466+ future isn't done. If None, then there is no limit on the
467+ wait time.
464468
465469 Returns:
466- The exception raised by the call that the future represents or None
467- if the call completed without raising.
470+ The exception raised by the call that the future represents or
471+ None if the call completed without raising.
468472
469473 Raises:
470474 CancelledError: If the future was cancelled.
471- TimeoutError: If the future didn't finish executing before the given
472- timeout.
475+ TimeoutError: If the future didn't finish executing before the
476+ given timeout.
473477 """
474478
475479 with self ._condition :
@@ -494,22 +498,23 @@ def set_running_or_notify_cancel(self):
494498 Should only be used by Executor implementations and unit tests.
495499
496500 If the future has been cancelled (cancel() was called and returned
497- True) then any threads waiting on the future completing (though calls
498- to as_completed() or wait()) are notified and False is returned.
501+ True) then any threads waiting on the future completing (though
502+ calls to as_completed() or wait()) are notified and False is
503+ returned.
499504
500505 If the future was not cancelled then it is put in the running state
501506 (future calls to running() will return True) and True is returned.
502507
503508 This method should be called by Executor implementations before
504- executing the work associated with this future. If this method returns
505- False then the work should not be executed.
509+ executing the work associated with this future. If this method
510+ returns False then the work should not be executed.
506511
507512 Returns:
508513 False if the Future was cancelled, True otherwise.
509514
510515 Raises:
511- RuntimeError: if this method was already called or if set_result()
512- or set_exception() was called.
516+ RuntimeError: if this method was already called or if
517+ set_result() or set_exception() was called.
513518 """
514519 with self ._condition :
515520 if self ._state == CANCELLED :
@@ -593,8 +598,9 @@ class Executor(object):
593598 def submit (self , fn , / , * args , ** kwargs ):
594599 """Submits a callable to be executed with the given arguments.
595600
596- Schedules the callable to be executed as fn(*args, **kwargs) and returns
597- a Future instance representing the execution of the callable.
601+ Schedules the callable to be executed as fn(*args, **kwargs) and
602+ returns a Future instance representing the execution of the
603+ callable.
598604
599605 Returns:
600606 A Future representing the given call.
@@ -607,25 +613,25 @@ def map(self, fn, *iterables, timeout=None, chunksize=1, buffersize=None):
607613 Args:
608614 fn: A callable that will take as many arguments as there are
609615 passed iterables.
610- timeout: The maximum number of seconds to wait. If None, then there
611- is no limit on the wait time.
612- chunksize: The size of the chunks the iterable will be broken into
613- before being passed to a child process. This argument is only
614- used by ProcessPoolExecutor; it is ignored by
616+ timeout: The maximum number of seconds to wait. If None, then
617+ there is no limit on the wait time.
618+ chunksize: The size of the chunks the iterable will be broken
619+ into before being passed to a child process. This argument
620+ is only used by ProcessPoolExecutor; it is ignored by
615621 ThreadPoolExecutor.
616622 buffersize: The number of submitted tasks whose results have not
617- yet been yielded. If the buffer is full, iteration over the
623+ yet been yielded. If the buffer is full, iteration over the
618624 iterables pauses until a result is yielded from the buffer.
619- If None, all input elements are eagerly collected, and a task is
620- submitted for each.
625+ If None, all input elements are eagerly collected, and
626+ a task is submitted for each.
621627
622628 Returns:
623- An iterator equivalent to: map(func, *iterables) but the calls may
624- be evaluated out-of-order.
629+ An iterator equivalent to: map(func, *iterables) but the calls
630+ may be evaluated out-of-order.
625631
626632 Raises:
627- TimeoutError: If the entire result iterator could not be generated
628- before the given timeout.
633+ TimeoutError: If the entire result iterator could not be
634+ generated before the given timeout.
629635 Exception: If fn(*args) raises for any values.
630636 """
631637 if buffersize is not None and not isinstance (buffersize , int ):
@@ -679,8 +685,8 @@ def shutdown(self, wait=True, *, cancel_futures=False):
679685
680686 Args:
681687 wait: If True then shutdown will not return until all running
682- futures have finished executing and the resources used by the
683- executor have been reclaimed.
688+ futures have finished executing and the resources used by
689+ the executor have been reclaimed.
684690 cancel_futures: If True then shutdown will cancel all pending
685691 futures. Futures that are completed or running will not be
686692 cancelled.
0 commit comments