]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Don't promise that coroutines waiting for a Lock are FIFO.
authorA. Jesse Jiryu Davis <jesse@mongodb.com>
Sat, 28 Feb 2015 18:35:36 +0000 (13:35 -0500)
committerA. Jesse Jiryu Davis <jesse@mongodb.com>
Sat, 28 Feb 2015 18:35:36 +0000 (13:35 -0500)
tornado/locks.py
tornado/test/locks_test.py

index c5ab59266a0edbd8c5f89b645259f16a1ad1c3b1..74aa898f9ea069be7f071cad93dfa95d1c2dc0f5 100644 (file)
@@ -264,9 +264,6 @@ class Lock(object):
     ...        pass
     ...
     ...    # Now the lock is released.
-
-    Coroutines waiting for `acquire` are granted the lock in first-in, first-out
-    order.
     """
     def __init__(self):
         self._block = BoundedSemaphore(value=1)
index 6da82bc44dbaad5ae48a84e6f5578b5b3e463a66..82504f9921b1b3027b6aabb75a15049b980110e6 100644 (file)
@@ -382,22 +382,20 @@ class LockTests(AsyncTestCase):
         self.assertTrue(future.done())
 
     @gen_test
-    def test_acquire_fifo(self):
+    def test_acquire_contended(self):
         lock = locks.Lock()
         self.assertTrue(lock.acquire().done())
         N = 5
-        history = []
 
         @gen.coroutine
-        def f(idx):
+        def f():
             with (yield lock.acquire()):
-                history.append(idx)
+                pass
 
-        futures = [f(i) for i in range(N)]
+        futures = [f() for _ in range(N)]
         self.assertFalse(any(future.done() for future in futures))
         lock.release()
         yield futures
-        self.assertEqual(range(N), history)
 
     @gen_test
     def test_acquire_timeout(self):