mò +á¸Ec@s_dZdkZdkZdkZdkZdklZd„Zedjoei ƒndS(s)ThreadLock tests >>> lock = ThreadLock.allocate_lock() >>> twoshouldstart = threading.Event() >>> n = 0 >>> readbytwo = None >>> def one(): ... global n ... lock.acquire() ... twoshouldstart.set() ... for i in range(10): ... time.sleep(.001) ... lock.acquire() ... n += 1 ... ... for i in range(10): ... time.sleep(.001) ... lock.release() ... ... lock.release() >>> def two(): ... global readbytwo ... twoshouldstart.wait() ... lock.acquire() ... readbytwo = n ... lock.release() >>> ttwo = threading.Thread(target=two) >>> ttwo.start() >>> time.sleep(0.001) >>> tone = threading.Thread(target=one) >>> tone.start() >>> tone.join() >>> ttwo.join() >>> readbytwo 10 $Id: tests.py,v 1.2 2003/11/28 16:46:39 jim Exp $ N(s DocTestSuitecCstitƒfƒS(N(tunittestt TestSuitet DocTestSuite(((t//data/zmath/zope/lib/python/ThreadLock/tests.pyt test_suite>st__main__( t__doc__t ThreadLockt threadingttimeRtzope.testing.doctestRRt__name__tmain(RRRRR R((Rt?8s