Exemple #1
0
 def test_reentrant_acquire(self):
     l = allocate1()
     l.acquire()
     try:
         l.acquire()
     except _ReentrantAcquireAssertion:
         return
     raise 'Failed to detect a reentrant acquire'
Exemple #2
0
 def test_reentrant_acquire(self):
     l = allocate1()
     l.acquire()
     try:
         l.acquire()
     except _ReentrantAcquireAssertion:
         return
     raise "Failed to detect a reentrant acquire"
Exemple #3
0
 def test_1_debug_on(self):
     l = allocate1()
     if l.owner is not None:
         raise 'Broken debugging code.'
     if l in l.locked_list:
         raise 'Broken debugging code.'
     l.acquire()
     if l not in l.locked_list:
         raise 'Broken debugging code.'
     if l.owner != currentThread():
         raise 'Broken debugging code.'
     return
Exemple #4
0
 def test_1_debug_on(self):
     l = allocate1()
     if l.owner is not None:
         raise "Broken debugging code."
     if l in l.locked_list:
         raise "Broken debugging code."
     l.acquire()
     if l not in l.locked_list:
         raise "Broken debugging code."
     if l.owner != currentThread():
         raise "Broken debugging code."
     return
Exemple #5
0
 def test_release_by_other_thread(self):
     def acquire_it_elsewhere(lock):
         lock.acquire()
     l = allocate1()
     test_thread = Thread(target=acquire_it_elsewhere,args=(l,))
     test_thread.start()
     while l not in l.locked_list:
         pause(0.1)
     try:
         l.release()
     except _WrongThreadAssertion:
         return
     raise "Failed to detect a release of another thread's acquire."
Exemple #6
0
    def test_release_by_other_thread(self):
        def acquire_it_elsewhere(lock):
            lock.acquire()

        l = allocate1()
        test_thread = Thread(target=acquire_it_elsewhere, args=(l,))
        test_thread.start()
        while l not in l.locked_list:
            pause(0.1)
        try:
            l.release()
        except _WrongThreadAssertion:
            return
        raise "Failed to detect a release of another thread's acquire."