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 6464 * Make `ClusterCommandsProtocol` an actual Protocol
6565 * Add `sum` to DUPLICATE_POLICY documentation of `TS.CREATE`, `TS.ADD` and `TS.ALTER`
6666 * 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)
6768
6869* 4.1.3 (Feb 8, 2022)
6970 * Fix flushdb and flushall (#1926)
Original file line number Diff line number Diff line change @@ -920,7 +920,12 @@ def _connect(self):
920920 "Create a Unix domain socket connection"
921921 sock = socket .socket (socket .AF_UNIX , socket .SOCK_STREAM )
922922 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
924929 sock .settimeout (self .socket_timeout )
925930 return sock
926931
You can’t perform that action at this time.
0 commit comments