Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(157371)

Side by Side Diff: Lib/test/test_multiprocessing.py

Issue 12156: test_multiprocessing.test_notify_all() timeout (1 hour) on FreeBSD 7.2
Patch Set: Created 7 years, 8 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python3 1 #!/usr/bin/env python3
2 2
3 # 3 #
4 # Unit tests for the multiprocessing package 4 # Unit tests for the multiprocessing package
5 # 5 #
6 6
7 import unittest 7 import unittest
8 import queue as pyqueue 8 import queue as pyqueue
9 import time 9 import time
10 import io 10 import io
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 107
108 # 108 #
109 # Some tests require ctypes 109 # Some tests require ctypes
110 # 110 #
111 111
112 try: 112 try:
113 from ctypes import Structure, c_int, c_double 113 from ctypes import Structure, c_int, c_double
114 except ImportError: 114 except ImportError:
115 Structure = object 115 Structure = object
116 c_int = c_double = None 116 c_int = c_double = None
117
118
119 def check_enough_semaphores():
120 """Check that the system supports enough semaphores to run the test."""
121 try:
122 nsems_max = os.sysconf("SC_SEM_NSEMS_MAX")
123 except (AttributeError, ValueError):
124 # sysconf not available or setting not available
125 return
126 if nsems_max == -1:
127 # indetermine limit, assume that limit is determined by available memory
128 # only
129 return
130 if nsems_max >= 256:
131 # minimum number of semaphores available according to POSIX
132 return
133 raise unittest.SkipTest("The OS doesn't support enough semaphores "
134 "to run the test.")
135
117 136
118 # 137 #
119 # Creates a wrapper for a function which records the time it takes to finish 138 # Creates a wrapper for a function which records the time it takes to finish
120 # 139 #
121 140
122 class TimingWrapper(object): 141 class TimingWrapper(object):
123 142
124 def __init__(self, func): 143 def __init__(self, func):
125 self.func = func 144 self.func = func
126 self.elapsed = None 145 self.elapsed = None
(...skipping 2214 matching lines...) Expand 10 before | Expand all | Expand 10 after
2341 # 2360 #
2342 # 2361 #
2343 # 2362 #
2344 2363
2345 def test_main(run=None): 2364 def test_main(run=None):
2346 if sys.platform.startswith("linux"): 2365 if sys.platform.startswith("linux"):
2347 try: 2366 try:
2348 lock = multiprocessing.RLock() 2367 lock = multiprocessing.RLock()
2349 except OSError: 2368 except OSError:
2350 raise unittest.SkipTest("OSError raises on RLock creation, see issue 3111!") 2369 raise unittest.SkipTest("OSError raises on RLock creation, see issue 3111!")
2370
2371 check_enough_semaphores()
2351 2372
2352 if run is None: 2373 if run is None:
2353 from test.support import run_unittest as run 2374 from test.support import run_unittest as run
2354 2375
2355 util.get_temp_dir() # creates temp directory for use by all processes 2376 util.get_temp_dir() # creates temp directory for use by all processes
2356 2377
2357 multiprocessing.get_logger().setLevel(LOG_LEVEL) 2378 multiprocessing.get_logger().setLevel(LOG_LEVEL)
2358 2379
2359 ProcessesMixin.pool = multiprocessing.Pool(4) 2380 ProcessesMixin.pool = multiprocessing.Pool(4)
2360 ThreadsMixin.pool = multiprocessing.dummy.Pool(4) 2381 ThreadsMixin.pool = multiprocessing.dummy.Pool(4)
(...skipping 17 matching lines...) Expand all
2378 ManagerMixin.pool.terminate() 2399 ManagerMixin.pool.terminate()
2379 ManagerMixin.manager.shutdown() 2400 ManagerMixin.manager.shutdown()
2380 2401
2381 del ProcessesMixin.pool, ThreadsMixin.pool, ManagerMixin.pool 2402 del ProcessesMixin.pool, ThreadsMixin.pool, ManagerMixin.pool
2382 2403
2383 def main(): 2404 def main():
2384 test_main(unittest.TextTestRunner(verbosity=2).run) 2405 test_main(unittest.TextTestRunner(verbosity=2).run)
2385 2406
2386 if __name__ == '__main__': 2407 if __name__ == '__main__':
2387 main() 2408 main()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+