In older versions of Requests there was option to turn off keep alive. Something like this:
s = requests.session()
s.config['keep_alive'] = False
I also find in other question that I can use header Connection: close
HTTP/1.1 defines the "close" connection option for the sender to signal
that the connection will be closed after completion of the response.
For example,
Connection: close
in either the request or the response header fields indicates that the
connection SHOULD NOT be considered `persistent' (section 8.1) after the
current request/response is complete.
HTTP/1.1 applications that do not support persistent connections MUST
include the "close" connection option in every message.
If I understand this properly it doesn't mean that connection will be closed. It's only information that it shouldn't be considered as persistent one.
How to do it in recent versions?