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():
4545 try :
4646 # This will throw an error if the metadata server isn't available,
4747 # 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
4950
5051 try :
5152 # This whole block is almost unnecessary. IMDSv1 will be supported
@@ -135,7 +136,8 @@ def azure_metadata():
135136 try :
136137 # This will throw an error if the metadata server isn't available,
137138 # 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
139141
140142 # Can't use newest metadata service version, as it's not guaranteed
141143 # to be available in all regions
You can’t perform that action at this time.
0 commit comments