Skip to content

Commit ac72b7f

Browse files
committed
For #36143: Explicitly closing download_attachment file handler (#114)
We want to ensure that we're explicitly closing our file handler in download_attachment, so that we don't throw an error in cases where Python's garbage collector doesn't close the file.
1 parent cf22401 commit ac72b7f

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

shotgun_api3/shotgun.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1612,6 +1612,8 @@ def download_attachment(self, attachment=False, file_path=None,
16121612
raise ShotgunFileDownloadError(err)
16131613
else:
16141614
if file_path:
1615+
if not fp.closed:
1616+
fp.close()
16151617
return file_path
16161618
else:
16171619
return attachment

0 commit comments

Comments
 (0)