Back to index

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

List of all members.

Public Member Functions

def wait_impl
def setUp
def f
def test_wait

Public Attributes

 alive
 stop

Detailed Description

Definition at line 14 of file test_wait4.py.


Member Function Documentation

def test.fork_wait.ForkWait.f (   self,
  id 
) [inherited]

Definition at line 26 of file fork_wait.py.

00026 
00027     def f(self, id):
00028         while not self.stop:
00029             self.alive[id] = os.getpid()
00030             try:
00031                 time.sleep(SHORTSLEEP)
00032             except IOError:
00033                 pass

Here is the caller graph for this function:

def test.fork_wait.ForkWait.setUp (   self) [inherited]

Definition at line 22 of file fork_wait.py.

00022 
00023     def setUp(self):
00024         self.alive = {}
00025         self.stop = 0

Here is the caller graph for this function:

def test.fork_wait.ForkWait.test_wait (   self) [inherited]

Definition at line 46 of file fork_wait.py.

00046 
00047     def test_wait(self):
00048         for i in range(NUM_THREADS):
00049             _thread.start_new(self.f, (i,))
00050 
00051         time.sleep(LONGSLEEP)
00052 
00053         a = sorted(self.alive.keys())
00054         self.assertEqual(a, list(range(NUM_THREADS)))
00055 
00056         prefork_lives = self.alive.copy()
00057 
00058         if sys.platform in ['unixware7']:
00059             cpid = os.fork1()
00060         else:
00061             cpid = os.fork()
00062 
00063         if cpid == 0:
00064             # Child
00065             time.sleep(LONGSLEEP)
00066             n = 0
00067             for key in self.alive:
00068                 if self.alive[key] != prefork_lives[key]:
00069                     n += 1
00070             os._exit(n)
00071         else:
00072             # Parent
00073             self.wait_impl(cpid)
00074             # Tell threads to die
00075             self.stop = 1
00076             time.sleep(2*SHORTSLEEP) # Wait for threads to die

Here is the call graph for this function:

def test.test_wait4.Wait4Test.wait_impl (   self,
  cpid 
)

Reimplemented from test.fork_wait.ForkWait.

Definition at line 15 of file test_wait4.py.

00015 
00016     def wait_impl(self, cpid):
00017         for i in range(10):
00018             # wait4() shouldn't hang, but some of the buildbots seem to hang
00019             # in the forking tests.  This is an attempt to fix the problem.
00020             spid, status, rusage = os.wait4(cpid, os.WNOHANG)
00021             if spid == cpid:
00022                 break
00023             time.sleep(1.0)
00024         self.assertEqual(spid, cpid)
00025         self.assertEqual(status, 0, "cause = %d, exit = %d" % (status&0xff, status>>8))
00026         self.assertTrue(rusage)

Here is the call graph for this function:


Member Data Documentation

Definition at line 23 of file fork_wait.py.

Definition at line 24 of file fork_wait.py.


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