Skip to content

Commit 4307aaa

Browse files
m-buchergerrod3
authored andcommitted
Fix leaking file descriptors in streamed download
Fixes #7157 Co-authored-by: Gerrod <gerrodubben@gmail.com>
1 parent 83667c0 commit 4307aaa

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
@@ -1335,6 +1335,12 @@ async def finalize():
13351335
"on-demand-downloading/#on-demand-and-streamed-limitations>"
13361336
)
13371337

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

0 commit comments

Comments
 (0)