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

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

Issue 9260: A finer grained import lock
Patch Set: Created 1 year 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 | « Lib/pydoc.py ('k') | Lib/test/test_pkg.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 """ 1 """
2 Various tests for synchronization primitives. 2 Various tests for synchronization primitives.
3 """ 3 """
4 4
5 import sys 5 import sys
6 import time 6 import time
7 from _thread import start_new_thread, TIMEOUT_MAX 7 from _thread import start_new_thread, TIMEOUT_MAX
8 import threading 8 import threading
9 import unittest 9 import unittest
10 10
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 lock.acquire() 240 lock.acquire()
241 lock.release() 241 lock.release()
242 lock.acquire() 242 lock.acquire()
243 lock.release() 243 lock.release()
244 lock.release() 244 lock.release()
245 245
246 def test_release_unacquired(self): 246 def test_release_unacquired(self):
247 # Cannot release an unacquired lock 247 # Cannot release an unacquired lock
248 lock = self.locktype() 248 lock = self.locktype()
249 self.assertRaises(RuntimeError, lock.release) 249 self.assertRaises(RuntimeError, lock.release)
250 self.assertRaises(RuntimeError, lock._release_save)
251 lock.acquire() 250 lock.acquire()
252 lock.acquire() 251 lock.acquire()
253 lock.release() 252 lock.release()
254 lock.acquire() 253 lock.acquire()
255 lock.release() 254 lock.release()
256 lock.release() 255 lock.release()
257 self.assertRaises(RuntimeError, lock.release) 256 self.assertRaises(RuntimeError, lock.release)
257
258 def test_release_save_unacquired(self):
259 # Cannot _release_save an unacquired lock
260 lock = self.locktype()
261 self.assertRaises(RuntimeError, lock._release_save)
262 lock.acquire()
263 lock.acquire()
264 lock.release()
265 lock.acquire()
266 lock.release()
267 lock.release()
258 self.assertRaises(RuntimeError, lock._release_save) 268 self.assertRaises(RuntimeError, lock._release_save)
259 269
260 def test_different_thread(self): 270 def test_different_thread(self):
261 # Cannot release from a different thread 271 # Cannot release from a different thread
262 lock = self.locktype() 272 lock = self.locktype()
263 def f(): 273 def f():
264 lock.acquire() 274 lock.acquire()
265 b = Bunch(f, 1, True) 275 b = Bunch(f, 1, True)
266 try: 276 try:
267 self.assertRaises(RuntimeError, lock.release) 277 self.assertRaises(RuntimeError, lock.release)
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 if i == self.N // 2: 867 if i == self.N // 2:
858 # One thread is later than the default timeout of 0.3s. 868 # One thread is later than the default timeout of 0.3s.
859 time.sleep(1.0) 869 time.sleep(1.0)
860 self.assertRaises(threading.BrokenBarrierError, barrier.wait) 870 self.assertRaises(threading.BrokenBarrierError, barrier.wait)
861 self.run_threads(f) 871 self.run_threads(f)
862 872
863 def test_single_thread(self): 873 def test_single_thread(self):
864 b = self.barriertype(1) 874 b = self.barriertype(1)
865 b.wait() 875 b.wait()
866 b.wait() 876 b.wait()
OLDNEW
« no previous file with comments | « Lib/pydoc.py ('k') | Lib/test/test_pkg.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld cbc36f91f3f7