File tree Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Original file line number Diff line number Diff line change 64
64
* Make `ClusterCommandsProtocol` an actual Protocol
65
65
* Add `sum` to DUPLICATE_POLICY documentation of `TS.CREATE`, `TS.ADD` and `TS.ALTER`
66
66
* Prevent async ClusterPipeline instances from becoming "false-y" in case of empty command stack (#3061)
67
+ * Close Unix sockets if the connection attempt fails. This prevents `ResourceWarning`s. (#3314)
67
68
68
69
* 4.1.3 (Feb 8, 2022)
69
70
* Fix flushdb and flushall (#1926)
Original file line number Diff line number Diff line change @@ -920,7 +920,12 @@ def _connect(self):
920
920
"Create a Unix domain socket connection"
921
921
sock = socket .socket (socket .AF_UNIX , socket .SOCK_STREAM )
922
922
sock .settimeout (self .socket_connect_timeout )
923
- sock .connect (self .path )
923
+ try :
924
+ sock .connect (self .path )
925
+ except OSError :
926
+ # Prevent ResourceWarnings for unclosed sockets.
927
+ sock .close ()
928
+ raise
924
929
sock .settimeout (self .socket_timeout )
925
930
return sock
926
931
You can’t perform that action at this time.
0 commit comments