Lines Matching defs:futures
25 from concurrent import futures
26 from concurrent.futures._base import (
29 from concurrent.futures.process import BrokenProcessPool, _check_system_limits
83 logger = logging.getLogger('concurrent.futures')
87 time.sleep(0.1) # let some futures be scheduled
151 executor_type = futures.ThreadPoolExecutor
155 executor_type = futures.ProcessPoolExecutor
169 executor_type = futures.ProcessPoolExecutor
181 executor_type = futures.ProcessPoolExecutor
225 futures = [self.executor.submit(get_init_status)
228 for f in futures:
281 with self.assertLogs('concurrent.futures', 'CRITICAL') as cm:
302 from concurrent.futures import {executor_type}
332 from concurrent.futures import {executor_type}
346 self.assertIn("RuntimeError: cannot schedule new futures", err.decode())
361 # the submitted futures should have been cancelled.
365 # Ensure the other futures were able to finish.
366 # Use "not fut.cancelled()" instead of "fut.done()" to include futures
373 # Similar to the number of cancelled futures, we can't guarantee the
379 """shutdown(wait=False) doesn't hang at exit with running futures.
383 if self.executor_type == futures.ProcessPoolExecutor:
388 from concurrent.futures import {executor_type}
444 with futures.ThreadPoolExecutor(max_workers=5) as e:
453 executor = futures.ThreadPoolExecutor(max_workers=5)
468 executor = futures.ThreadPoolExecutor(max_workers=5)
481 executor = futures.ThreadPoolExecutor(
493 executor = futures.ThreadPoolExecutor(max_workers=5)
509 from concurrent.futures import ThreadPoolExecutor
547 with futures.ProcessPoolExecutor(
557 executor = futures.ProcessPoolExecutor(
581 executor = futures.ProcessPoolExecutor(
611 done, not_done = futures.wait([future, future],
612 return_when=futures.ALL_COMPLETED)
621 done, not_done = futures.wait(
623 return_when=futures.FIRST_COMPLETED)
631 finished, pending = futures.wait(
633 return_when=futures.FIRST_COMPLETED)
645 finished, pending = futures.wait(
647 return_when=futures.FIRST_EXCEPTION)
656 finished, pending = futures.wait(
661 return_when=futures.FIRST_EXCEPTION)
671 finished, pending = futures.wait(
673 return_when=futures.FIRST_EXCEPTION)
682 finished, pending = futures.wait(
688 return_when=futures.ALL_COMPLETED)
701 finished, pending = futures.wait(
707 return_when=futures.ALL_COMPLETED)
720 # futures.
729 futures.wait(fs, return_when=futures.ALL_COMPLETED)
746 completed = set(futures.as_completed(
762 for future in futures.as_completed(
769 except futures.TimeoutError:
778 # Issue 20367. Duplicate futures should not raise exceptions or give
783 f for f in futures.as_completed(itertools.repeat(future1, 3))
789 # to finished futures.
794 with self.assertRaises(futures.TimeoutError):
795 for future in futures.as_completed(futures_list, timeout=0):
803 for future in futures.as_completed(futures_list):
816 with self.assertRaises(futures.TimeoutError) as cm:
817 list(futures.as_completed(futures_list, timeout=0))
819 self.assertEqual(str(cm.exception), '2 (of 4) futures unfinished')
864 except futures.TimeoutError:
955 with futures.ThreadPoolExecutor(1) as pool:
959 with futures.ProcessPoolExecutor(1, mp_context=mp.get_context('fork')) as workers:
986 # ident='third' is cancelled because it remained in the collection of futures
996 futures.ProcessPoolExecutor(max_workers=62)
1001 futures = [self.executor.submit(time.sleep, 3)]
1005 for fut in futures:
1041 self.assertIs(type(cause), futures.process._RemoteTraceback)
1148 futures = []
1150 futures.append(executor.submit(mul, i, i))
1152 for i, future in enumerate(futures):
1269 except futures.TimeoutError:
1549 self.assertRaises(futures.TimeoutError,
1551 self.assertRaises(futures.TimeoutError,
1553 self.assertRaises(futures.CancelledError,
1555 self.assertRaises(futures.CancelledError,
1585 self.assertRaises(futures.CancelledError,
1590 self.assertRaises(futures.TimeoutError,
1592 self.assertRaises(futures.TimeoutError,
1594 self.assertRaises(futures.CancelledError,
1596 self.assertRaises(futures.CancelledError,
1623 futures.InvalidStateError,
1638 futures.InvalidStateError,