From: A. Jesse Jiryu Davis Date: Sat, 28 Feb 2015 18:35:36 +0000 (-0500) Subject: Don't promise that coroutines waiting for a Lock are FIFO. X-Git-Tag: v4.2.0b1~89^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=30a80a09c2f1943e4c476eda26247efb5ce0bda3;p=thirdparty%2Ftornado.git Don't promise that coroutines waiting for a Lock are FIFO. --- diff --git a/tornado/locks.py b/tornado/locks.py index c5ab59266..74aa898f9 100644 --- a/tornado/locks.py +++ b/tornado/locks.py @@ -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) diff --git a/tornado/test/locks_test.py b/tornado/test/locks_test.py index 6da82bc44..82504f992 100644 --- a/tornado/test/locks_test.py +++ b/tornado/test/locks_test.py @@ -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):