Lines Matching full:executor
120 self.executor = self.executor_type(
125 self.executor = self.executor_type(
131 self.executor.shutdown(wait=True)
132 self.executor = None
145 # Make sure that the executor is ready to do work before running the
147 futures = [self.executor.submit(time.sleep, 0.1)
213 futures = [self.executor.submit(get_init_status)
241 future = self.executor.submit(get_init_status)
243 # Perhaps the executor is already broken
248 # At some point, the executor should break
250 while not self.executor._broken:
252 self.fail("executor not broken after 5 s.")
256 self.executor.submit(get_init_status)
285 self.executor.shutdown()
287 self.executor.submit,
341 fs = [self.executor.submit(time.sleep, 0.1) for _ in range(50)]
342 self.executor.shutdown()
347 executor = self.executor_type(max_workers=3)
348 fs = [executor.submit(time.sleep, .1) for _ in range(50)]
349 executor.shutdown(cancel_futures=True)
400 self.executor.submit(acquire_lock, sem)
401 self.assertEqual(len(self.executor._threads), 3)
404 self.executor.shutdown()
405 for t in self.executor._threads:
410 executor = e
414 for t in executor._threads:
418 executor = futures.ThreadPoolExecutor(max_workers=5)
419 res = executor.map(abs, range(-5, 5))
420 threads = executor._threads
421 del executor
427 # executor got shutdown.
431 # Ensure that the executor cleans up the threads when calling
433 executor = futures.ThreadPoolExecutor(max_workers=5)
434 res = executor.map(abs, range(-5, 5))
435 threads = executor._threads
436 executor.shutdown(wait=False)
441 # executor got shutdown.
446 executor = futures.ThreadPoolExecutor(
448 executor.map(abs, range(-5, 5))
449 threads = executor._threads
450 del executor
457 executor = futures.ThreadPoolExecutor(max_workers=5)
458 executor.map(abs, range(-5, 5))
459 threads = executor._threads
460 del executor
496 self.executor.submit(acquire_lock, sem)
497 self.assertEqual(len(self.executor._processes), 3)
500 processes = self.executor._processes
501 self.executor.shutdown()
516 executor = futures.ProcessPoolExecutor(max_workers=5)
517 res = executor.map(abs, range(-5, 5))
518 executor_manager_thread = executor._executor_manager_thread
519 processes = executor._processes
520 call_queue = executor._call_queue
521 executor_manager_thread = executor._executor_manager_thread
522 del executor
524 # Make sure that all the executor resources were properly cleaned by
532 # executor got shutdown.
536 # Ensure that the executor cleans up the processes when calling
538 executor = futures.ProcessPoolExecutor(max_workers=5)
539 res = executor.map(abs, range(-5, 5))
540 processes = executor._processes
541 call_queue = executor._call_queue
542 executor_manager_thread = executor._executor_manager_thread
543 executor.shutdown(wait=False)
545 # Make sure that all the executor resources were properly cleaned by
552 # Make sure the results were all computed before the executor got
566 future1 = self.executor.submit(mul, 21, 2)
567 future2 = self.executor.submit(time.sleep, 1.5)
577 future1 = self.executor.submit(time.sleep, 1.5)
589 future1 = self.executor.submit(mul, 2, 21)
590 future2 = self.executor.submit(sleep_and_raise, 1.5)
591 future3 = self.executor.submit(time.sleep, 3)
601 future1 = self.executor.submit(divmod, 21, 0)
602 future2 = self.executor.submit(time.sleep, 1.5)
617 future1 = self.executor.submit(time.sleep, 2)
627 future1 = self.executor.submit(divmod, 2, 0)
628 future2 = self.executor.submit(mul, 2, 21)
646 future1 = self.executor.submit(mul, 6, 7)
647 future2 = self.executor.submit(time.sleep, 6)
675 fs = {self.executor.submit(future_func) for i in range(100)}
691 future1 = self.executor.submit(mul, 2, 21)
692 future2 = self.executor.submit(mul, 7, 6)
707 future1 = self.executor.submit(time.sleep, 2)
729 future1 = self.executor.submit(time.sleep, 2)
772 # Executor.shutdown() and context manager usage is tested by
775 future = self.executor.submit(pow, 2, 8)
779 future = self.executor.submit(mul, 2, y=8)
781 future = self.executor.submit(capture, 1, self=2, fn=3)
784 self.executor.submit(fn=capture, arg=1)
786 self.executor.submit(arg=1)
790 list(self.executor.map(pow, range(10), range(10))),
794 list(self.executor.map(pow, range(10), range(10), chunksize=3)),
798 i = self.executor.map(divmod, [1, 1, 1, 1], [2, 3, 0, 5])
806 for i in self.executor.map(time.sleep,
821 self.executor.map(str, [2] * (self.worker_count + 1))
822 self.executor.shutdown()
833 self.executor.submit(my_object.my_method)
850 for obj in self.executor.map(make_dummy_object, range(10)):
863 self.executor.map(record_finished, range(10))
864 self.executor.shutdown(wait=True)
868 executor = self.executor_type()
870 self.assertEqual(executor._max_workers, expected)
873 executor = self.executor_type(4)
878 for i in range(15 * executor._max_workers):
879 executor.submit(acquire_lock, sem)
880 self.assertEqual(len(executor._threads), executor._max_workers)
881 for i in range(15 * executor._max_workers):
883 executor.shutdown(wait=True)
886 executor = self.executor_type()
887 executor.submit(mul, 21, 2).result()
888 executor.submit(mul, 6, 7).result()
889 executor.submit(mul, 3, 14).result()
890 self.assertEqual(len(executor._threads), 1)
891 executor.shutdown(wait=True)
905 futures = [self.executor.submit(time.sleep, 3)]
907 p = next(iter(self.executor._processes.values()))
912 self.assertRaises(BrokenProcessPool, self.executor.submit, pow, 2, 8)
916 list(self.executor.map(pow, range(40), range(40), chunksize=-1))
920 list(self.executor.map(pow, range(40), range(40), chunksize=6)),
923 list(self.executor.map(pow, range(40), range(40), chunksize=50)),
926 list(self.executor.map(pow, range(40), range(40), chunksize=40)),
937 future = self.executor.submit(self._test_traceback)
962 future = self.executor.submit(id, obj)
976 executor = self.executor_type(4)
979 job_count = 15 * executor._max_workers
982 executor.submit(sem.acquire)
983 self.assertEqual(len(executor._processes), executor._max_workers)
987 executor.shutdown()
990 executor = self.executor_type(4)
991 executor.submit(mul, 21, 2).result()
992 executor.submit(mul, 6, 7).result()
993 executor.submit(mul, 3, 14).result()
994 self.assertEqual(len(executor._processes), 1)
995 executor.shutdown()
998 executor = self.executor_type(4)
999 executor.submit(mul, 12, 7).result()
1000 executor.submit(mul, 33, 25)
1001 executor.submit(mul, 25, 26).result()
1002 executor.submit(mul, 18, 29)
1003 self.assertLessEqual(len(executor._processes), 2)
1004 executor.shutdown()
1083 def _fail_on_deadlock(self, executor): argument
1085 # executor is in a deadlock state and forcefully clean all its
1093 for p in executor._processes.values():
1095 # This should be safe to call executor.shutdown here as all possible
1097 executor.shutdown(wait=True)
1099 self.fail(f"Executor deadlock:\n\n{tb}")
1104 self.executor.shutdown(wait=True)
1106 executor = self.executor_type(
1108 res = executor.submit(func, *args)
1121 # consider that the executor is in a deadlock state
1122 self._fail_on_deadlock(executor)
1123 executor.shutdown(wait=True)
1184 self.executor.shutdown(wait=True)
1186 mp_context=get_context(self.ctx)) as executor:
1187 self.executor = executor # Allow clean up in fail_on_deadlock
1188 f = executor.submit(_crash, delay=.1)
1189 executor.shutdown(wait=True)
1197 self.executor.shutdown(wait=True)
1199 mp_context=get_context(self.ctx)) as executor:
1200 self.executor = executor # Allow clean up in fail_on_deadlock
1202 # Start the executor and get the executor_manager_thread to collect
1205 executor.submit(id, 42).result()
1206 executor_manager = executor._executor_manager_thread
1208 # Submit a task that fails at pickle and shutdown the executor
1210 f = executor.submit(id, ErrorAtPickle())
1211 executor.shutdown(wait=False)
1215 # Make sure the executor is eventually shutdown and do not leave