diff --git a/Pipfile b/Pipfile index 5bacb0a..5cc1317 100644 --- a/Pipfile +++ b/Pipfile @@ -4,7 +4,6 @@ verify_ssl = true name = "pypi" [packages] -async-timeout = "~=3.0.1" [dev-packages] black = "*" @@ -12,4 +11,4 @@ flake8 = "*" pydocstyle = "~=4.0.0" pytest = "~=6.2.3" pytest-asyncio = "~=0.15.1" -mypy = "*" \ No newline at end of file +mypy = "*" diff --git a/Pipfile.lock b/Pipfile.lock index 216028c..1670a13 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,12 +1,10 @@ { "_meta": { "hash": { - "sha256": "94f0f4790efc443878e1340cadba9239cd32309fe8c9c831712d1e757aef1ffa" + "sha256": "e1ac82277132512ba749ea8996291af36edddfe42171564b84536e340971a889" }, "pipfile-spec": 6, - "requires": { - "python_version": ">=3.7" - }, + "requires": {}, "sources": [ { "name": "pypi", @@ -15,17 +13,7 @@ } ] }, - "default": { - "async-timeout": { - "hashes": [ - "sha256:0c3c816a028d47f659d6ff5c745cb2acf1f966da1fe5c19c77a70282b25f4c5f", - "sha256:4291ca197d287d274d0b6cb5d6f8f8f82d434ed288f962539ff18cc9012f9ea3" - ], - "index": "pypi", - "markers": "python_full_version >= '3.5.3'", - "version": "==3.0.1" - } - }, + "default": {}, "develop": { "attrs": { "hashes": [ diff --git a/aiosocketpool/__init__.py b/aiosocketpool/__init__.py index 04ca089..fb28f18 100644 --- a/aiosocketpool/__init__.py +++ b/aiosocketpool/__init__.py @@ -9,8 +9,6 @@ from typing import Optional, Type, AsyncGenerator import weakref -import async_timeout - def can_use_kqueue(): # kqueue doesn't work on OS X 10.6 and below @@ -171,8 +169,9 @@ async def connect(self) -> bool: loop = asyncio.get_event_loop() - with async_timeout.timeout(self.timeout): - await loop.sock_connect(self._socket, (self.host, self.port)) + await asyncio.wait_for( + loop.sock_connect(self._socket, (self.host, self.port)), self.timeout + ) if not is_connected(self._socket): raise SocketPoolException(f"Connection to {self.host}:{self.port} failed") @@ -228,8 +227,7 @@ async def sendall(self, data: bytes): """ loop = asyncio.get_event_loop() - with async_timeout.timeout(self.timeout): - return await loop.sock_sendall(self._socket, data) + return await asyncio.wait_for(loop.sock_sendall(self._socket, data), self.timeout) async def recv(self, size: int = 1024) -> bytes: """Receive some data from the remote host. @@ -247,8 +245,7 @@ async def recv(self, size: int = 1024) -> bytes: """ loop = asyncio.get_event_loop() - with async_timeout.timeout(self.timeout): - return await loop.sock_recv(self._socket, size) + return await asyncio.wait_for(loop.sock_recv(self._socket, size), self.timeout) async def recv_exactly(self, size: int) -> bytes: """Receive an exact amount of data from the remote host. diff --git a/requirements.txt b/requirements.txt index 8df1ac1..e4f81fa 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1 @@ -i https://pypi.org/simple -async-timeout==3.0.1 --hash=sha256:0c3c816a028d47f659d6ff5c745cb2acf1f966da1fe5c19c77a70282b25f4c5f --hash=sha256:4291ca197d287d274d0b6cb5d6f8f8f82d434ed288f962539ff18cc9012f9ea3 diff --git a/setup.py b/setup.py index 61f4572..9cade6f 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,6 @@ name="aiosocketpool", version=__version__, # type: ignore packages=find_packages(exclude=["*test*"]), - install_requires=["async_timeout>=3.0.1"], extras_require={ "testing": [ "black>=19.3b0",