canonical / canonical/cloud-init

tcp: Re-use tcp sessions

Open
#5,286 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
3.8k
Forks
1.1k
Avg merge
2d 23h
Merged PRs (30d)
18

Description

# Bug report
While investigating https://github.com/canonical/cloud-init/pull/5144, I realized that the code that is supposed to be re-using TCP session doesn't work correctly. The Session object gets re-used, however each individual call to `readurl()` ultimately creates a new session.

Session creation -> https://github.com/canonical/cloud-init/blob/120adcc1917a7e1157ad82615c202bf1a8d231fe/cloudinit/url_helper.py#L445

To reuse connections, we should create the session context outside of `readurl()`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.