Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes
test.test_thread.TestForkInThread Class Reference

List of all members.

Public Member Functions

def setUp
def test_forkinthread
def tearDown

Public Attributes

 write_fd

Detailed Description

Definition at line 197 of file test_thread.py.


Member Function Documentation

Definition at line 198 of file test_thread.py.

00198 
00199     def setUp(self):
00200         self.read_fd, self.write_fd = os.pipe()

Here is the caller graph for this function:

Definition at line 224 of file test_thread.py.

00224 
00225     def tearDown(self):
00226         try:
00227             os.close(self.read_fd)
00228         except OSError:
00229             pass
00230 
00231         try:
00232             os.close(self.write_fd)
00233         except OSError:
00234             pass
00235 

Here is the caller graph for this function:

Definition at line 204 of file test_thread.py.

00204 
00205     def test_forkinthread(self):
00206         def thread1():
00207             try:
00208                 pid = os.fork() # fork in a thread
00209             except RuntimeError:
00210                 os._exit(1) # exit the child
00211 
00212             if pid == 0: # child
00213                 try:
00214                     os.close(self.read_fd)
00215                     os.write(self.write_fd, b"OK")
00216                 finally:
00217                     os._exit(0)
00218             else: # parent
00219                 os.close(self.write_fd)
00220 
00221         thread.start_new_thread(thread1, ())
00222         self.assertEqual(os.read(self.read_fd, 2), b"OK",
00223                          "Unable to fork() in thread")

Here is the call graph for this function:


Member Data Documentation

Definition at line 199 of file test_thread.py.


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