<p dir="auto">I am experiencing a race condition with a (Squid) proxy server, best described by <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/rdharrison2/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/rdharrison2">@rdharrison2</a> in <a href="https://github.com/kennethreitz/requests/issues/2364#issuecomment-186214402">https://github.com/kennethreitz/requests/issues/2364#issuecomment-186214402</a>:</p>
<blockquote>
<p dir="auto">In my case I'm making a large number of periodic https requests to a apache2 server with connection keep-alive timeout 5s. There is a race between the server closing a timed out persistent connection and the client making a request on the same connection. Given a bit of network latency the client can often attempt to send a request on the socket before it gets notified it as been closed.</p>
</blockquote>
<p dir="auto">Rather than implementing a retry logic, I would like to ensure that my requests <code class="notranslate">Session</code> keep-alive "timeout" is lower than that of proxy's. But I cannot seem to find out how.</p>
<p dir="auto">Either I'm blind or it's just not supported?</p>
<p dir="auto">Request hooks are being <a href="https://github.com/kennethreitz/requests/blob/master/requests/sessions.py#L264">merged</a> with session hooks; since both hook dicts have a list as the value, one simply overwrites the other.</p>