Skip to content

Commit 2576269

Browse files
m-buchergerrod3
authored andcommitted
Fix leaking file descriptors in streamed download
Fixes #7157 Co-authored-by: Gerrod <[email protected]> (cherry picked from commit 4307aaa)
1 parent a2ca70c commit 2576269

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

CHANGES/7157.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed file handle leak when content app access triggers downloads due to on_demand or streamed policy.

pulpcore/content/handler.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,6 +1334,12 @@ async def finalize():
13341334
"on-demand-downloading/#on-demand-and-streamed-limitations>"
13351335
)
13361336

1337+
# manually close the DownloadFactory's (HTTP-)session, the next artifact-download will
1338+
# create a new DownloadFactory anyway because it will use a new remote-object.
1339+
# Leaving it open also left open file-descriptors to /dev/urandom. Most likely these FDs are
1340+
# held by the underlying SSL library.
1341+
await downloader.session.close()
1342+
13371343
if save_artifact and remote.policy != Remote.STREAMED:
13381344
content_artifacts = await asyncio.shield(
13391345
sync_to_async(self._save_artifact)(download_result, remote_artifact, request)

0 commit comments

Comments
 (0)