Back to index

python3.2  3.2.2
Classes | Functions | Variables
test.test_multiprocessing Namespace Reference

Classes

class  TimingWrapper
class  BaseTestCase
class  _TestProcess
class  _UpperCaser
class  _TestSubclassingProcess
class  _TestQueue
class  _TestLock
class  _TestSemaphore
class  _TestCondition
class  _TestEvent
class  _TestValue
class  _TestArray
class  _TestContainers
class  _TestPool
class  _TestPoolWorkerErrors
class  _TestPoolWorkerLifetime
class  _TestZZZNumberOfObjects
class  FooBar
class  IteratorProxy
class  MyManager
class  _TestMyManager
class  QueueManager
class  QueueManager2
class  _TestRemoteManager
class  _TestManagerRestart
class  _TestConnection
class  _TestListenerClient
class  _TestHeap
class  _Foo
class  _TestSharedCTypes
class  _TestFinalize
class  _TestImportStar
class  _TestLogging
class  TestInvalidHandle
class  ProcessesMixin
class  ManagerMixin
class  ThreadsMixin
class  OtherTest
class  TestInitializers
class  _file_like
class  TestStdinBadfiledescriptor

Functions

def latin
def get_value
def queue_empty
def queue_full
def sqr
def raising
def unpickleable_result
def baz
def get_queue
def get_attributes
def create_test_cases
def initializer
def _ThisSubProcess
def _TestProcess
def _afunc
def pool_in_process
def test_main
def main

Variables

tuple _multiprocessing = test.support.import_module('_multiprocessing')
 HAS_SHAREDCTYPES = True
 LOG_LEVEL = util.SUBWARNING
float DELTA = 0.1
 CHECK_TIMINGS = False
tuple HAVE_GETVALUE
tuple WIN32 = (sys.platform == "win32")
 Structure = object
 c_int = c_doubleNone
tuple _queue = pyqueue.Queue()
string SERIALIZER = 'xmlrpclib'
tuple SENTINEL = latin('')
tuple testcases_processes = create_test_cases(ProcessesMixin, type='processes')
tuple testcases_manager = create_test_cases(ManagerMixin, type='manager')
tuple testcases_threads = create_test_cases(ThreadsMixin, type='threads')
list testcases_other

Function Documentation

def test.test_multiprocessing._afunc (   x) [private]

Definition at line 2088 of file test_multiprocessing.py.

02088 
02089 def _afunc(x):
02090     return x*x

Definition at line 2082 of file test_multiprocessing.py.

02082 
02083 def _TestProcess(q):
02084     queue = multiprocessing.Queue()
02085     subProc = multiprocessing.Process(target=_ThisSubProcess, args=(queue,))
02086     subProc.start()
02087     subProc.join()

Here is the call graph for this function:

Definition at line 2076 of file test_multiprocessing.py.

02076 
02077 def _ThisSubProcess(q):
02078     try:
02079         item = q.get(block=False)
02080     except pyqueue.Empty:
02081         pass

Definition at line 1233 of file test_multiprocessing.py.

01233 
01234 def baz():
01235     for i in range(10):
01236         yield i*i

def test.test_multiprocessing.create_test_cases (   Mixin,
  type 
)

Definition at line 1950 of file test_multiprocessing.py.

01950 
01951 def create_test_cases(Mixin, type):
01952     result = {}
01953     glob = globals()
01954     Type = type.capitalize()
01955 
01956     for name in list(glob.keys()):
01957         if name.startswith('_Test'):
01958             base = glob[name]
01959             if type in base.ALLOWED_TYPES:
01960                 newname = 'With' + Type + name[1:]
01961                 class Temp(base, unittest.TestCase, Mixin):
01962                     pass
01963                 result[newname] = Temp
01964                 Temp.__name__ = newname
01965                 Temp.__module__ = Mixin.__module__
01966     return result
01967 
01968 #
01969 # Create test cases
01970 #

def test.test_multiprocessing.get_attributes (   Source,
  names 
)

Definition at line 1941 of file test_multiprocessing.py.

01941 
01942 def get_attributes(Source, names):
01943     d = {}
01944     for name in names:
01945         obj = getattr(Source, name)
01946         if type(obj) == type(get_attributes):
01947             obj = staticmethod(obj)
01948         d[name] = obj
01949     return d

Here is the call graph for this function:

Definition at line 1289 of file test_multiprocessing.py.

01289 
01290 def get_queue():
01291     return _queue

Definition at line 133 of file test_multiprocessing.py.

00133 
00134 def get_value(self):
00135     try:
00136         return self.get_value()
00137     except AttributeError:
00138         try:
00139             return self._Semaphore__value
00140         except AttributeError:
00141             try:
00142                 return self._value
00143             except AttributeError:
00144                 raise NotImplementedError
00145 
00146 #
00147 # Testcases
00148 #

Here is the caller graph for this function:

Definition at line 2045 of file test_multiprocessing.py.

02045 
02046 def initializer(ns):
02047     ns.test += 1

Here is the caller graph for this function:

Definition at line 50 of file test_multiprocessing.py.

00050 
00051 def latin(s):
00052     return s.encode('latin')
00053 
00054 #
00055 # Constants
00056 #

Here is the caller graph for this function:

Definition at line 2182 of file test_multiprocessing.py.

02182 
02183 def main():
02184     test_main(unittest.TextTestRunner(verbosity=2).run)

Here is the call graph for this function:

Definition at line 2091 of file test_multiprocessing.py.

02091 
02092 def pool_in_process():
02093     pool = multiprocessing.Pool(processes=4)
02094     x = pool.map(_afunc, [1, 2, 3, 4, 5, 6, 7])

Here is the call graph for this function:

Definition at line 340 of file test_multiprocessing.py.

00340 
00341 def queue_empty(q):
00342     if hasattr(q, 'empty'):
00343         return q.empty()
00344     else:
00345         return q.qsize() == 0

Here is the caller graph for this function:

def test.test_multiprocessing.queue_full (   q,
  maxsize 
)

Definition at line 346 of file test_multiprocessing.py.

00346 
00347 def queue_full(q, maxsize):
00348     if hasattr(q, 'full'):
00349         return q.full()
00350     else:
00351         return q.qsize() == maxsize
00352 

Here is the caller graph for this function:

Definition at line 1118 of file test_multiprocessing.py.

01118 
01119 def raising():
01120     raise KeyError("key")

def test.test_multiprocessing.sqr (   x,
  wait = 0.0 
)

Definition at line 1035 of file test_multiprocessing.py.

01035 
01036 def sqr(x, wait=0.0):
01037     time.sleep(wait)
01038     return x*x

Here is the caller graph for this function:

Definition at line 2144 of file test_multiprocessing.py.

02144 
02145 def test_main(run=None):
02146     if sys.platform.startswith("linux"):
02147         try:
02148             lock = multiprocessing.RLock()
02149         except OSError:
02150             raise unittest.SkipTest("OSError raises on RLock creation, see issue 3111!")
02151 
02152     if run is None:
02153         from test.support import run_unittest as run
02154 
02155     util.get_temp_dir()     # creates temp directory for use by all processes
02156 
02157     multiprocessing.get_logger().setLevel(LOG_LEVEL)
02158 
02159     ProcessesMixin.pool = multiprocessing.Pool(4)
02160     ThreadsMixin.pool = multiprocessing.dummy.Pool(4)
02161     ManagerMixin.manager.__init__()
02162     ManagerMixin.manager.start()
02163     ManagerMixin.pool = ManagerMixin.manager.Pool(4)
02164 
02165     testcases = (
02166         sorted(testcases_processes.values(), key=lambda tc:tc.__name__) +
02167         sorted(testcases_threads.values(), key=lambda tc:tc.__name__) +
02168         sorted(testcases_manager.values(), key=lambda tc:tc.__name__) +
02169         testcases_other
02170         )
02171 
02172     loadTestsFromTestCase = unittest.defaultTestLoader.loadTestsFromTestCase
02173     suite = unittest.TestSuite(loadTestsFromTestCase(tc) for tc in testcases)
02174     run(suite)
02175 
02176     ThreadsMixin.pool.terminate()
02177     ProcessesMixin.pool.terminate()
02178     ManagerMixin.pool.terminate()
02179     ManagerMixin.manager.shutdown()
02180 
02181     del ProcessesMixin.pool, ThreadsMixin.pool, ManagerMixin.pool

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1121 of file test_multiprocessing.py.

01121 
01122 def unpickleable_result():
01123     return lambda: 42


Variable Documentation

Definition at line 24 of file test_multiprocessing.py.

tuple test.test_multiprocessing._queue = pyqueue.Queue()

Definition at line 1288 of file test_multiprocessing.py.

Definition at line 83 of file test_multiprocessing.py.

Definition at line 61 of file test_multiprocessing.py.

Definition at line 60 of file test_multiprocessing.py.

Definition at line 42 of file test_multiprocessing.py.

Initial value:
00001 notgetattr(_multiprocessing,
00002                             'HAVE_BROKEN_SEM_GETVALUE', False)

Definition at line 70 of file test_multiprocessing.py.

Definition at line 57 of file test_multiprocessing.py.

Definition at line 1389 of file test_multiprocessing.py.

Definition at line 1301 of file test_multiprocessing.py.

Definition at line 82 of file test_multiprocessing.py.

Definition at line 1995 of file test_multiprocessing.py.

Initial value:
00001 [OtherTest, TestInvalidHandle, TestInitializers,
00002                    TestStdinBadfiledescriptor]

Definition at line 2137 of file test_multiprocessing.py.

Definition at line 1981 of file test_multiprocessing.py.

Definition at line 2009 of file test_multiprocessing.py.

tuple test.test_multiprocessing.WIN32 = (sys.platform == "win32")

Definition at line 73 of file test_multiprocessing.py.