Back to index

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

List of all members.

Public Member Functions

def test_pool_worker_lifetime
def assertTimingAlmostEqual
def assertReturnsIfImplemented
def __reduce__

Public Attributes

_PyObject_HEAD_EXTRA Py_ssize_t ob_refcnt
struct _typeobjectob_type

Static Public Attributes

tuple ALLOWED_TYPES = ('processes', )

Detailed Description

Definition at line 1164 of file test_multiprocessing.py.


Member Function Documentation

def test.test_multiprocessing.BaseTestCase.__reduce__ (   self,
  args 
) [inherited]

Definition at line 124 of file test_multiprocessing.py.

00124 
00125     def __reduce__(self, *args):
00126         raise NotImplementedError("shouldn't try to pickle a test case")

def test.test_multiprocessing.BaseTestCase.assertReturnsIfImplemented (   self,
  value,
  func,
  args 
) [inherited]

Definition at line 114 of file test_multiprocessing.py.

00114 
00115     def assertReturnsIfImplemented(self, value, func, *args):
00116         try:
00117             res = func(*args)
00118         except NotImplementedError:
00119             pass
00120         else:
00121             return self.assertEqual(value, res)

Here is the call graph for this function:

Here is the caller graph for this function:

def test.test_multiprocessing.BaseTestCase.assertTimingAlmostEqual (   self,
  a,
  b 
) [inherited]

Definition at line 110 of file test_multiprocessing.py.

00110 
00111     def assertTimingAlmostEqual(self, a, b):
00112         if CHECK_TIMINGS:
00113             self.assertAlmostEqual(a, b, 1)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1167 of file test_multiprocessing.py.

01167 
01168     def test_pool_worker_lifetime(self):
01169         p = multiprocessing.Pool(3, maxtasksperchild=10)
01170         self.assertEqual(3, len(p._pool))
01171         origworkerpids = [w.pid for w in p._pool]
01172         # Run many tasks so each worker gets replaced (hopefully)
01173         results = []
01174         for i in range(100):
01175             results.append(p.apply_async(sqr, (i, )))
01176         # Fetch the results and verify we got the right answers,
01177         # also ensuring all the tasks have completed.
01178         for (j, res) in enumerate(results):
01179             self.assertEqual(res.get(), sqr(j))
01180         # Refill the pool
01181         p._repopulate_pool()
01182         # Wait until all workers are alive
01183         # (countdown * DELTA = 5 seconds max startup process time)
01184         countdown = 50
01185         while countdown and not all(w.is_alive() for w in p._pool):
01186             countdown -= 1
01187             time.sleep(DELTA)
01188         finalworkerpids = [w.pid for w in p._pool]
01189         # All pids should be assigned.  See issue #7805.
01190         self.assertNotIn(None, origworkerpids)
01191         self.assertNotIn(None, finalworkerpids)
01192         # Finally, check that the worker pids have changed
01193         self.assertNotEqual(sorted(origworkerpids), sorted(finalworkerpids))
01194         p.close()
01195         p.join()
01196 
01197 #
01198 # Test that manager has expected number of shared objects left
01199 #

Here is the call graph for this function:


Member Data Documentation

Reimplemented from test.test_multiprocessing.BaseTestCase.

Definition at line 1165 of file test_multiprocessing.py.

Definition at line 107 of file object.h.

struct _typeobject* _object::ob_type [inherited]

Definition at line 108 of file object.h.


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