Skip to content

Commit 2e4f5ca

Browse files
authored
Merge pull request #40 from aaugustin/patch-1
Avoid leaking an open socket
2 parents 60ee725 + f9454a5 commit 2e4f5ca

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

python_socks/async_/asyncio/_connect.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ async def connect_tcp(
2525
else:
2626
address = (host, port) # type: ignore[assignment]
2727

28-
await loop.sock_connect(sock=sock, address=address)
28+
try:
29+
await loop.sock_connect(sock=sock, address=address)
30+
except OSError:
31+
sock.close()
32+
raise
2933
return sock
3034

3135

0 commit comments

Comments
 (0)