From 30a80a09c2f1943e4c476eda26247efb5ce0bda3 Mon Sep 17 00:00:00 2001 From: "A. Jesse Jiryu Davis" Date: Sat, 28 Feb 2015 13:35:36 -0500 Subject: [PATCH] Don't promise that coroutines waiting for a Lock are FIFO. --- tornado/locks.py | 3 --- tornado/test/locks_test.py | 10 ++++------ 2 files changed, 4 insertions(+), 9 deletions(-) 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): -- 2.47.2