summary refs log tree commit diff
path: root/tests/util
diff options
context:
space:
mode:
authorSean Quah <8349537+squahtx@users.noreply.github.com>2022-04-05 15:43:52 +0100
committerGitHub <noreply@github.com>2022-04-05 15:43:52 +0100
commit800ba87cc881856adae19ec40485578356398639 (patch)
treecb19370283b7def590239b507c5dc5c72e39af8a /tests/util
parentMerge branch 'master' into develop (diff)
downloadsynapse-800ba87cc881856adae19ec40485578356398639.tar.xz
Refactor and convert `Linearizer` to async (#12357)
Refactor and convert `Linearizer` to async. This makes a `Linearizer`
cancellation bug easier to fix.

Also refactor to use an async context manager, which eliminates an
unlikely footgun where code that doesn't immediately use the context
manager could forget to release the lock.

Signed-off-by: Sean Quah <seanq@element.io>
Diffstat (limited to '')
-rw-r--r--tests/util/test_linearizer.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/tests/util/test_linearizer.py b/tests/util/test_linearizer.py
index fa132391a1..c2a209e637 100644
--- a/tests/util/test_linearizer.py
+++ b/tests/util/test_linearizer.py
@@ -46,7 +46,7 @@ class LinearizerTestCase(unittest.TestCase):
         unblock_d: "Deferred[None]" = Deferred()
 
         async def task() -> None:
-            with await linearizer.queue(key):
+            async with linearizer.queue(key):
                 acquired_d.callback(None)
                 await unblock_d
 
@@ -125,7 +125,7 @@ class LinearizerTestCase(unittest.TestCase):
 
         async def func(i: int) -> None:
             with LoggingContext("func(%s)" % i) as lc:
-                with (await linearizer.queue(key)):
+                async with linearizer.queue(key):
                     self.assertEqual(current_context(), lc)
 
                 self.assertEqual(current_context(), lc)