mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-24 03:11:24 -07:00
Close all open filehandle (#50544)
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
parent
94a1d86d70
commit
db8702cdb8
21 changed files with 81 additions and 47 deletions
|
@ -88,12 +88,11 @@ class RabbitClient():
|
|||
''' Consider some file size limits here '''
|
||||
def _read_file(self, path):
|
||||
try:
|
||||
fh = open(path, "rb").read()
|
||||
with open(path, "rb") as file_handle:
|
||||
return file_handle.read()
|
||||
except IOError as e:
|
||||
self.module.fail_json(msg="Unable to open file %s: %s" % (path, to_native(e)))
|
||||
|
||||
return fh
|
||||
|
||||
@staticmethod
|
||||
def _check_file_mime_type(path):
|
||||
mime = MimeTypes()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue