]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
locks: Convert to native coroutines
authorBen Darnell <ben@bendarnell.com>
Sun, 14 Oct 2018 17:43:33 +0000 (13:43 -0400)
committerBen Darnell <ben@bendarnell.com>
Sun, 14 Oct 2018 17:43:33 +0000 (13:43 -0400)
tornado/locks.py

index 20d21b5594a7b5080909ba4a5dc7e2523c4ebdb1..0da19766c45bbdbd4d0a3581ef67b701aa5729d7 100644 (file)
@@ -20,7 +20,7 @@ import types
 from tornado import gen, ioloop
 from tornado.concurrent import Future, future_set_result_unless_cancelled
 
-from typing import Union, Optional, Type, Any, Generator
+from typing import Union, Optional, Type, Any
 import typing
 
 if typing.TYPE_CHECKING:
@@ -453,9 +453,8 @@ class Semaphore(_TimeoutGarbageCollector):
     ) -> None:
         self.__enter__()
 
-    @gen.coroutine
-    def __aenter__(self) -> Generator[Any, Any, None]:
-        yield self.acquire()
+    async def __aenter__(self) -> None:
+        await self.acquire()
 
     async def __aexit__(
         self,
@@ -562,9 +561,8 @@ class Lock(object):
     ) -> None:
         self.__enter__()
 
-    @gen.coroutine
-    def __aenter__(self) -> Generator[Any, Any, None]:
-        yield self.acquire()
+    async def __aenter__(self) -> None:
+        await self.acquire()
 
     async def __aexit__(
         self,