Back to index

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

List of all members.

Public Member Functions

def test_processes_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.ProcessPoolExecutor
int worker_count = 5

Private Member Functions

def _prime_executor

Detailed Description

Definition at line 145 of file test_concurrent_futures.py.


Member Function Documentation

Reimplemented from test.test_concurrent_futures.ExecutorMixin.

Definition at line 146 of file test_concurrent_futures.py.

00146 
00147     def _prime_executor(self):
00148         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 160 of file test_concurrent_futures.py.

00160 
00161     def test_context_manager_shutdown(self):
00162         with futures.ProcessPoolExecutor(max_workers=5) as e:
00163             processes = e._processes
00164             self.assertEqual(list(e.map(abs, range(-5, 5))),
00165                              [5, 4, 3, 2, 1, 0, 1, 2, 3, 4])
00166 
00167         for p in processes:
00168             p.join()

Here is the call graph for this function:

Definition at line 169 of file test_concurrent_futures.py.

00169 
00170     def test_del_shutdown(self):
00171         executor = futures.ProcessPoolExecutor(max_workers=5)
00172         list(executor.map(abs, range(-5, 5)))
00173         queue_management_thread = executor._queue_management_thread
00174         processes = executor._processes
00175         del executor
00176 
00177         queue_management_thread.join()
00178         for p in processes:
00179             p.join()

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 149 of file test_concurrent_futures.py.

00149 
00150     def test_processes_terminate(self):
00151         self.executor.submit(mul, 21, 2)
00152         self.executor.submit(mul, 6, 7)
00153         self.executor.submit(mul, 3, 14)
00154         self.assertEqual(len(self.executor._processes), 5)
00155         processes = self.executor._processes
00156         self.executor.shutdown()
00157 
00158         for p in processes:
00159             p.join()

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:


Member Data Documentation

Definition at line 61 of file test_concurrent_futures.py.

test.test_concurrent_futures.ProcessPoolMixin.executor_type = futures.ProcessPoolExecutor [static, inherited]

Definition at line 88 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: