Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ verify_ssl = true
name = "pypi"

[packages]
async-timeout = "~=3.0.1"

[dev-packages]
black = "*"
flake8 = "*"
pydocstyle = "~=4.0.0"
pytest = "~=6.2.3"
pytest-asyncio = "~=0.15.1"
mypy = "*"
mypy = "*"
18 changes: 3 additions & 15 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 5 additions & 8 deletions aiosocketpool/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
-i https://pypi.org/simple
async-timeout==3.0.1 --hash=sha256:0c3c816a028d47f659d6ff5c745cb2acf1f966da1fe5c19c77a70282b25f4c5f --hash=sha256:4291ca197d287d274d0b6cb5d6f8f8f82d434ed288f962539ff18cc9012f9ea3
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down