Close http clients after using

The crystal http client maintains a keepalive connection to the other
server which stays alive for some time. This should be closed if the
client instance is not used again to avoid hogging resources
This commit is contained in:
Andrew Zhao
2020-12-23 00:52:23 -05:00
parent eeeecf9763
commit e0d25ff887
6 changed files with 30 additions and 11 deletions

View File

@@ -269,6 +269,8 @@ def fetch_reddit_comments(id, sort_by = "confidence")
raise InfoException.new("Could not fetch comments")
end
client.close
comments = result[1].data.as(RedditListing).children
return comments, thread
end