Lines Matching refs:executor
126 self.executor = self.executor_type(
131 self.executor = self.executor_type(
136 self.executor.shutdown(wait=True)
137 self.executor = None
225 futures = [self.executor.submit(get_init_status)
253 future = self.executor.submit(get_init_status)
255 # Perhaps the executor is already broken
260 # At some point, the executor should break
262 while not self.executor._broken:
264 self.fail("executor not broken after 5 s.")
268 self.executor.submit(get_init_status)
294 self.executor.shutdown()
296 self.executor.submit,
350 fs = [self.executor.submit(time.sleep, 0.1) for _ in range(50)]
351 self.executor.shutdown()
357 fs = [self.executor.submit(time.sleep, .1) for _ in range(50)]
358 self.executor.shutdown(cancel_futures=True)
416 executor = self.executor_type(max_workers=1, **kwargs)
417 executor.submit(int).result()
421 executor.submit(int).cancel()
422 executor.shutdown(wait=True)
435 self.executor.submit(acquire_lock, sem)
436 self.assertEqual(len(self.executor._threads), 3)
439 self.executor.shutdown()
440 for t in self.executor._threads:
445 executor = e
449 for t in executor._threads:
453 executor = futures.ThreadPoolExecutor(max_workers=5)
454 res = executor.map(abs, range(-5, 5))
455 threads = executor._threads
456 del executor
462 # executor got shutdown.
466 # Ensure that the executor cleans up the threads when calling
468 executor = futures.ThreadPoolExecutor(max_workers=5)
469 res = executor.map(abs, range(-5, 5))
470 threads = executor._threads
471 executor.shutdown(wait=False)
476 # executor got shutdown.
481 executor = futures.ThreadPoolExecutor(
483 executor.map(abs, range(-5, 5))
484 threads = executor._threads
485 del executor
493 executor = futures.ThreadPoolExecutor(max_workers=5)
494 executor.map(abs, range(-5, 5))
495 threads = executor._threads
496 del executor
536 self.executor.submit(acquire_lock, sem)
537 self.assertEqual(len(self.executor._processes), expected_num_processes)
540 processes = self.executor._processes
541 self.executor.shutdown()
557 executor = futures.ProcessPoolExecutor(
559 res = executor.map(abs, range(-5, 5))
560 executor_manager_thread = executor._executor_manager_thread
561 processes = executor._processes
562 call_queue = executor._call_queue
563 executor_manager_thread = executor._executor_manager_thread
564 del executor
567 # Make sure that all the executor resources were properly cleaned by
575 # executor got shutdown.
579 # Ensure that the executor cleans up the processes when calling
581 executor = futures.ProcessPoolExecutor(
583 res = executor.map(abs, range(-5, 5))
584 processes = executor._processes
585 call_queue = executor._call_queue
586 executor_manager_thread = executor._executor_manager_thread
587 executor.shutdown(wait=False)
589 # Make sure that all the executor resources were properly cleaned by
596 # Make sure the results were all computed before the executor got
610 future = self.executor.submit(time.sleep, 1.5)
618 future1 = self.executor.submit(mul, 21, 2)
619 future2 = self.executor.submit(time.sleep, 1.5)
629 future1 = self.executor.submit(time.sleep, 1.5)
641 future1 = self.executor.submit(mul, 2, 21)
642 future2 = self.executor.submit(sleep_and_raise, 1.5)
643 future3 = self.executor.submit(time.sleep, 3)
653 future1 = self.executor.submit(divmod, 21, 0)
654 future2 = self.executor.submit(time.sleep, 1.5)
669 future1 = self.executor.submit(time.sleep, 2)
679 future1 = self.executor.submit(divmod, 2, 0)
680 future2 = self.executor.submit(mul, 2, 21)
698 future1 = self.executor.submit(mul, 6, 7)
699 future2 = self.executor.submit(time.sleep, 6)
727 fs = {self.executor.submit(future_func) for i in range(100)}
743 future1 = self.executor.submit(mul, 2, 21)
744 future2 = self.executor.submit(mul, 7, 6)
759 future1 = self.executor.submit(time.sleep, 2)
781 future1 = self.executor.submit(time.sleep, 2)
829 future = self.executor.submit(pow, 2, 8)
833 future = self.executor.submit(mul, 2, y=8)
835 future = self.executor.submit(capture, 1, self=2, fn=3)
838 self.executor.submit(fn=capture, arg=1)
840 self.executor.submit(arg=1)
844 list(self.executor.map(pow, range(10), range(10))),
848 list(self.executor.map(pow, range(10), range(10), chunksize=3)),
852 i = self.executor.map(divmod, [1, 1, 1, 1], [2, 3, 0, 5])
860 for i in self.executor.map(time.sleep,
875 self.executor.map(str, [2] * (self.worker_count + 1))
876 self.executor.shutdown()
887 self.executor.submit(my_object.my_method)
904 for obj in self.executor.map(make_dummy_object, range(10)):
918 self.executor.map(record_finished, range(10))
919 self.executor.shutdown(wait=True)
923 executor = self.executor_type()
925 self.assertEqual(executor._max_workers, expected)
928 executor = self.executor_type(4)
933 for i in range(15 * executor._max_workers):
934 executor.submit(acquire_lock, sem)
935 self.assertEqual(len(executor._threads), executor._max_workers)
936 for i in range(15 * executor._max_workers):
938 executor.shutdown(wait=True)
941 executor = self.executor_type()
942 executor.submit(mul, 21, 2).result()
943 executor.submit(mul, 6, 7).result()
944 executor.submit(mul, 3, 14).result()
945 self.assertEqual(len(executor._threads), 1)
946 executor.shutdown(wait=True)
1001 futures = [self.executor.submit(time.sleep, 3)]
1003 p = next(iter(self.executor._processes.values()))
1008 self.assertRaises(BrokenProcessPool, self.executor.submit, pow, 2, 8)
1012 list(self.executor.map(pow, range(40), range(40), chunksize=-1))
1016 list(self.executor.map(pow, range(40), range(40), chunksize=6)),
1019 list(self.executor.map(pow, range(40), range(40), chunksize=50)),
1022 list(self.executor.map(pow, range(40), range(40), chunksize=40)),
1033 future = self.executor.submit(self._test_traceback)
1058 future = self.executor.submit(id, obj)
1072 executor = self.executor
1075 job_count = 15 * executor._max_workers
1077 executor.submit(sem.acquire)
1078 self.assertEqual(len(executor._processes), executor._max_workers)
1083 executor = self.executor
1084 assert executor._max_workers >= 4
1087 executor.submit(mul, 21, 2).result()
1088 executor.submit(mul, 6, 7).result()
1089 executor.submit(mul, 3, 14).result()
1090 self.assertEqual(len(executor._processes), 1)
1093 executor = self.executor
1094 assert executor._max_workers <= 5
1097 executor.submit(mul, 12, 7).result()
1098 executor.submit(mul, 33, 25)
1099 executor.submit(mul, 25, 26).result()
1100 executor.submit(mul, 18, 29)
1101 executor.submit(mul, 1, 2).result()
1102 executor.submit(mul, 0, 9)
1103 self.assertLessEqual(len(executor._processes), 3)
1104 executor.shutdown()
1112 # not using self.executor as we need to control construction.
1114 executor = self.executor_type(
1116 f1 = executor.submit(os.getpid)
1119 f2 = executor.submit(os.getpid)
1121 self.assertEqual(len(executor._processes), 1)
1122 f3 = executor.submit(os.getpid)
1127 f4 = executor.submit(os.getpid)
1130 self.assertEqual(len(executor._processes), 1)
1132 executor.shutdown()
1135 # not using self.executor as we need to control construction.
1137 executor = self.executor_type(1, max_tasks_per_child=3)
1138 self.assertEqual(executor._mp_context.get_start_method(), "spawn")
1144 # not using self.executor as we need to control construction.
1146 executor = self.executor_type(
1150 futures.append(executor.submit(mul, i, i))
1151 executor.shutdown()
1233 def _fail_on_deadlock(self, executor):
1235 # executor is in a deadlock state and forcefully clean all its
1243 for p in executor._processes.values():
1245 # This should be safe to call executor.shutdown here as all possible
1247 executor.shutdown(wait=True)
1254 self.executor.shutdown(wait=True)
1256 executor = self.executor_type(
1258 res = executor.submit(func, *args)
1271 # consider that the executor is in a deadlock state
1272 self._fail_on_deadlock(executor)
1273 executor.shutdown(wait=True)
1334 self.executor.shutdown(wait=True)
1336 mp_context=self.get_context()) as executor:
1337 self.executor = executor # Allow clean up in fail_on_deadlock
1338 f = executor.submit(_crash, delay=.1)
1339 executor.shutdown(wait=True)
1347 self.executor.shutdown(wait=True)
1349 mp_context=self.get_context()) as executor:
1350 self.executor = executor # Allow clean up in fail_on_deadlock
1352 # Start the executor and get the executor_manager_thread to collect
1355 executor.submit(id, 42).result()
1356 executor_manager = executor._executor_manager_thread
1358 # Submit a task that fails at pickle and shutdown the executor
1360 f = executor.submit(id, ErrorAtPickle())
1361 executor.shutdown(wait=False)
1365 # Make sure the executor is eventually shutdown and do not leave