Back to index

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

List of all members.

Public Member Functions

def test_listener_client
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', 'threads')

Private Member Functions

def _test

Detailed Description

Definition at line 1541 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._TestListenerClient._test (   cls,
  address 
) [private]

Definition at line 1546 of file test_multiprocessing.py.

01546 
01547     def _test(cls, address):
01548         conn = cls.connection.Client(address)
01549         conn.send('hello')
01550         conn.close()

Here is the caller graph for this function:

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 1551 of file test_multiprocessing.py.

01551 
01552     def test_listener_client(self):
01553         for family in self.connection.families:
01554             l = self.connection.Listener(family=family)
01555             p = self.Process(target=self._test, args=(l.address,))
01556             p.daemon = True
01557             p.start()
01558             conn = l.accept()
01559             self.assertEqual(conn.recv(), 'hello')
01560             p.join()
01561             l.close()
01562 #
01563 # Test of sending connection and socket objects between processes
01564 #
01565 """
01566 class _TestPicklingConnections(BaseTestCase):
01567 
01568     ALLOWED_TYPES = ('processes',)
01569 
01570     def _listener(self, conn, families):
01571         for fam in families:
01572             l = self.connection.Listener(family=fam)
01573             conn.send(l.address)
01574             new_conn = l.accept()
01575             conn.send(new_conn)
01576 
01577         if self.TYPE == 'processes':
01578             l = socket.socket()
01579             l.bind(('localhost', 0))
01580             conn.send(l.getsockname())
01581             l.listen(1)
01582             new_conn, addr = l.accept()
01583             conn.send(new_conn)
01584 
01585         conn.recv()
01586 
01587     def _remote(self, conn):
01588         for (address, msg) in iter(conn.recv, None):
01589             client = self.connection.Client(address)
01590             client.send(msg.upper())
01591             client.close()
01592 
01593         if self.TYPE == 'processes':
01594             address, msg = conn.recv()
01595             client = socket.socket()
01596             client.connect(address)
01597             client.sendall(msg.upper())
01598             client.close()
01599 
01600         conn.close()
01601 
01602     def test_pickling(self):
01603         try:
01604             multiprocessing.allow_connection_pickling()
01605         except ImportError:
01606             return
01607 
01608         families = self.connection.families
01609 
01610         lconn, lconn0 = self.Pipe()
01611         lp = self.Process(target=self._listener, args=(lconn0, families))
01612         lp.start()
01613         lconn0.close()
01614 
01615         rconn, rconn0 = self.Pipe()
01616         rp = self.Process(target=self._remote, args=(rconn0,))
01617         rp.start()
01618         rconn0.close()
01619 
01620         for fam in families:
01621             msg = ('This connection uses family %s' % fam).encode('ascii')
01622             address = lconn.recv()
01623             rconn.send((address, msg))
01624             new_conn = lconn.recv()
01625             self.assertEqual(new_conn.recv(), msg.upper())
01626 
01627         rconn.send(None)
01628 
01629         if self.TYPE == 'processes':
01630             msg = latin('This connection uses a normal socket')
01631             address = lconn.recv()
01632             rconn.send((address, msg))
01633             if hasattr(socket, 'fromfd'):
01634                 new_conn = lconn.recv()
01635                 self.assertEqual(new_conn.recv(100), msg.upper())
01636             else:
01637                 # XXX On Windows with Py2.6 need to backport fromfd()
01638                 discard = lconn.recv_bytes()
01639 
01640         lconn.send(None)
01641 
01642         rconn.close()
01643         lconn.close()
01644 
01645         lp.join()
01646         rp.join()
01647 """
01648 #
01649 #
01650 #

Here is the call graph for this function:


Member Data Documentation

tuple test.test_multiprocessing._TestListenerClient.ALLOWED_TYPES = ('processes', 'threads') [static]

Reimplemented from test.test_multiprocessing.BaseTestCase.

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