comparison mercurial/keepalive.py @ 49542:8251f7cc787d stable

keepalive: ensure `close_all()` actually closes all cached connections While debugging why LFS blob downloads are getting corrupted with workers, I noticed that prior to spinning up the workers, the ConnectionManager has 2 connections to the server and calling `KeepAliveHandler.close_all()` left one behind. The reason is the value component of `self._cm.get_all().items()` is a list, and `self._cm.remove()` modifies said list while the caller is iterating over it. Now `get_all()` is a deep copy of both the dict and lists in all cases.
author Matt Harbison <matt_harbison@yahoo.com>
date Tue, 18 Oct 2022 11:54:58 -0400
parents 48f1b314056b
children 76fbb1b6692a
comparison
equal deleted inserted replaced
49540:bc2ecf08ae04 49542:8251f7cc787d
164 164
165 def get_all(self, host=None): 165 def get_all(self, host=None):
166 if host: 166 if host:
167 return list(self._hostmap[host]) 167 return list(self._hostmap[host])
168 else: 168 else:
169 return dict(self._hostmap) 169 return dict(
170 {h: list(conns) for (h, conns) in self._hostmap.items()}
171 )
170 172
171 173
172 class KeepAliveHandler: 174 class KeepAliveHandler:
173 def __init__(self, timeout=None): 175 def __init__(self, timeout=None):
174 self._cm = ConnectionManager() 176 self._cm = ConnectionManager()