[Python-checkins] CVS: python/dist/src/Lib/test test_fork1.py,1.1,1.2

Fred Drake python-dev@python.org
2000年4月10日 11:36:42 -0400


Update of /projects/cvsroot/python/dist/src/Lib/test
In directory seahag.cnri.reston.va.us:/home/fdrake/projects/python/Lib/test
Modified Files:
	test_fork1.py 
Log Message:
Use a constant to specify the number of child threads to create.
Instead of assuming that the number process ids of the threads is the
same as the process id of the controlling process, use a copy of the
dictionary and check for changes in the process ids of the threads
from the thread's process ids in the parent process. This makes the
test make more sense on systems which assign a new pid to each thread
(i.e., Linux).
This doesn't fix the other problems evident with this test on Linux.
Index: test_fork1.py
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Lib/test/test_fork1.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** test_fork1.py	2000年02月25日 19:24:58	1.1
--- test_fork1.py	2000年04月10日 15:36:39	1.2
***************
*** 15,18 ****
--- 15,20 ----
 SHORTSLEEP = 0.5
 
+ NUM_THREADS = 4
+ 
 alive = {}
 
***************
*** 26,30 ****
 
 def main():
! for i in range(4):
 thread.start_new(f, (i,))
 
--- 28,32 ----
 
 def main():
! for i in range(NUM_THREADS):
 thread.start_new(f, (i,))
 
***************
*** 33,37 ****
 a = alive.keys()
 a.sort()
! assert a == range(4)
 
 cpid = os.fork()
--- 35,41 ----
 a = alive.keys()
 a.sort()
! assert a == range(NUM_THREADS)
! 
! prefork_lives = alive.copy()
 
 cpid = os.fork()
***************
*** 41,47 ****
 time.sleep(LONGSLEEP)
 n = 0
- pid = os.getpid()
 for key in alive.keys():
! if alive[key] == pid:
 n = n+1
 os._exit(n)
--- 45,50 ----
 time.sleep(LONGSLEEP)
 n = 0
 for key in alive.keys():
! if alive[key] != prefork_lives[key]:
 n = n+1
 os._exit(n)

AltStyle によって変換されたページ (->オリジナル) /