From: Ben Darnell Date: Sun, 14 Oct 2018 17:43:33 +0000 (-0400) Subject: locks: Convert to native coroutines X-Git-Tag: v6.0.0b1~23^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7f16b43380467055b3a4210d3453afbd10b3aee7;p=thirdparty%2Ftornado.git locks: Convert to native coroutines --- diff --git a/tornado/locks.py b/tornado/locks.py index 20d21b559..0da19766c 100644 --- a/tornado/locks.py +++ b/tornado/locks.py @@ -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,