File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -45,7 +45,8 @@ def aws_metadata():
45
45
try :
46
46
# This will throw an error if the metadata server isn't available,
47
47
# and will be quiet in the logs, unlike urllib3
48
- socket .create_connection (("169.254.169.254" , 80 ), 0.1 )
48
+ with socket .create_connection (("169.254.169.254" , 80 ), 0.1 ):
49
+ pass
49
50
50
51
try :
51
52
# This whole block is almost unnecessary. IMDSv1 will be supported
@@ -135,7 +136,8 @@ def azure_metadata():
135
136
try :
136
137
# This will throw an error if the metadata server isn't available,
137
138
# and will be quiet in the logs, unlike urllib3
138
- socket .create_connection (("169.254.169.254" , 80 ), 0.1 )
139
+ with socket .create_connection (("169.254.169.254" , 80 ), 0.1 ):
140
+ pass
139
141
140
142
# Can't use newest metadata service version, as it's not guaranteed
141
143
# to be available in all regions
You can’t perform that action at this time.
0 commit comments