Skip to content
Merged
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
6 changes: 3 additions & 3 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ sphinx:

python:
install:
- method: pip
path: .
extra_requirements:
- method: uv
command: sync
groups:
- docs
10 changes: 7 additions & 3 deletions examples/custom_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,14 @@ def create(self, endpoint: Endpoint, timeout: Optional[float] = None) -> socket.
addr, port = endpoint

sock = socket.socket(family=socket.AF_INET, type=socket.SOCK_STREAM)
sock.connect((str(addr), port))
try:
sock.connect((str(addr), port))

if (resp := self.cmd(sock, f'AUTH {self._username} {self._password}')) != '+OK':
raise RuntimeError(f"authentication failed: {resp}")
if (resp := self.cmd(sock, f'AUTH {self._username} {self._password}')) != '+OK':
raise RuntimeError(f"authentication failed: {resp}")
except BaseException:
sock.close()
raise

return sock

Expand Down
9 changes: 6 additions & 3 deletions generic_connection_pool/contrib/socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,12 @@ def create(self, endpoint: TcpEndpoint, timeout: Optional[float] = None) -> sock
raise RuntimeError("unsupported address version type: %s", addr.version)

sock = socket.socket(family=family, type=socket.SOCK_STREAM)

with socket_timeout(sock, timeout):
sock.connect((str(addr), port))
try:
with socket_timeout(sock, timeout):
sock.connect((str(addr), port))
except BaseException:
sock.close()
raise

return sock

Expand Down
9 changes: 6 additions & 3 deletions generic_connection_pool/contrib/socket_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,12 @@ async def create(self, endpoint: TcpEndpoint) -> socket.socket:
raise RuntimeError("unsupported address version type: %s", addr.version)

sock = socket.socket(family=family, type=socket.SOCK_STREAM)
sock.setblocking(False)

await loop.sock_connect(sock, address=(str(addr), port))
try:
sock.setblocking(False)
await loop.sock_connect(sock, address=(str(addr), port))
except BaseException:
sock.close()
raise

return sock

Expand Down
8 changes: 6 additions & 2 deletions generic_connection_pool/contrib/unix.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,12 @@ class UnixSocketConnectionManager(
def create(self, endpoint: UnixSocketEndpoint, timeout: Optional[float] = None) -> socket.socket:
sock = socket.socket(family=socket.AF_UNIX, type=socket.SOCK_STREAM)

with socket_timeout(sock, timeout):
sock.connect(str(endpoint))
try:
with socket_timeout(sock, timeout):
sock.connect(str(endpoint))
except BaseException:
sock.close()
raise

return sock

Expand Down
9 changes: 6 additions & 3 deletions generic_connection_pool/contrib/unix_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@ async def create(self, endpoint: UnixSocketEndpoint) -> socket.socket:
loop = asyncio.get_running_loop()

sock = socket.socket(family=socket.AF_UNIX, type=socket.SOCK_STREAM)
sock.setblocking(False)

await loop.sock_connect(sock, address=(str(endpoint)))
try:
sock.setblocking(False)
await loop.sock_connect(sock, address=(str(endpoint)))
except BaseException:
sock.close()
raise

return sock

Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ classifiers = [
"Topic :: Software Development :: Libraries",
"Topic :: System :: Networking",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
Expand Down