Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions
test.test_concurrent_futures.ThreadPoolShutdownTest Class Reference
Inheritance diagram for test.test_concurrent_futures.ThreadPoolShutdownTest:
Inheritance graph
[legend]
Collaboration diagram for test.test_concurrent_futures.ThreadPoolShutdownTest:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def test_threads_terminate
def test_context_manager_shutdown
def test_del_shutdown
def setUp
def tearDown
def test_run_after_shutdown
def test_interpreter_shutdown

Public Attributes

 t1
 executor

Static Public Attributes

 executor_type = futures.ThreadPoolExecutor
int worker_count = 5

Private Member Functions

def _prime_executor

Detailed Description

Definition at line 113 of file test_concurrent_futures.py.


Member Function Documentation

Reimplemented from test.test_concurrent_futures.ExecutorMixin.

Definition at line 114 of file test_concurrent_futures.py.

00114 
00115     def _prime_executor(self):
00116         pass

Definition at line 58 of file test_concurrent_futures.py.

00058 
00059     def setUp(self):
00060         self.t1 = time.time()
00061         try:
00062             self.executor = self.executor_type(max_workers=self.worker_count)
00063         except NotImplementedError as e:
00064             self.skipTest(str(e))
00065         self._prime_executor()

Here is the caller graph for this function:

Definition at line 66 of file test_concurrent_futures.py.

00066 
00067     def tearDown(self):
00068         self.executor.shutdown(wait=True)
00069         dt = time.time() - self.t1
00070         if test.support.verbose:
00071             print("%.2fs" % dt, end=' ')
00072         self.assertLess(dt, 60, "synchronization issue: test lasted too long")

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 126 of file test_concurrent_futures.py.

00126 
00127     def test_context_manager_shutdown(self):
00128         with futures.ThreadPoolExecutor(max_workers=5) as e:
00129             executor = e
00130             self.assertEqual(list(e.map(abs, range(-5, 5))),
00131                              [5, 4, 3, 2, 1, 0, 1, 2, 3, 4])
00132 
00133         for t in executor._threads:
00134             t.join()

Here is the call graph for this function:

Definition at line 135 of file test_concurrent_futures.py.

00135 
00136     def test_del_shutdown(self):
00137         executor = futures.ThreadPoolExecutor(max_workers=5)
00138         executor.map(abs, range(-5, 5))
00139         threads = executor._threads
00140         del executor
00141 
00142         for t in threads:
00143             t.join()
00144 

Definition at line 98 of file test_concurrent_futures.py.

00098 
00099     def test_interpreter_shutdown(self):
00100         # Test the atexit hook for shutdown of worker threads and processes
00101         rc, out, err = assert_python_ok('-c', """if 1:
00102             from concurrent.futures import {executor_type}
00103             from time import sleep
00104             from test.test_concurrent_futures import sleep_and_print
00105             t = {executor_type}(5)
00106             t.submit(sleep_and_print, 1.0, "apple")
00107             """.format(executor_type=self.executor_type.__name__))
00108         # Errors in atexit hooks don't change the process exit code, check
00109         # stderr manually.
00110         self.assertFalse(err)
00111         self.assertEqual(out.strip(), b"apple")
00112 

Here is the call graph for this function:

Definition at line 92 of file test_concurrent_futures.py.

00092 
00093     def test_run_after_shutdown(self):
00094         self.executor.shutdown()
00095         self.assertRaises(RuntimeError,
00096                           self.executor.submit,
00097                           pow, 2, 5)

Here is the call graph for this function:

Definition at line 117 of file test_concurrent_futures.py.

00117 
00118     def test_threads_terminate(self):
00119         self.executor.submit(mul, 21, 2)
00120         self.executor.submit(mul, 6, 7)
00121         self.executor.submit(mul, 3, 14)
00122         self.assertEqual(len(self.executor._threads), 3)
00123         self.executor.shutdown()
00124         for t in self.executor._threads:
00125             t.join()

Here is the call graph for this function:


Member Data Documentation

Definition at line 61 of file test_concurrent_futures.py.

test.test_concurrent_futures.ThreadPoolMixin.executor_type = futures.ThreadPoolExecutor [static, inherited]

Definition at line 84 of file test_concurrent_futures.py.

Definition at line 59 of file test_concurrent_futures.py.

Definition at line 56 of file test_concurrent_futures.py.


The documentation for this class was generated from the following file: