Mercurial > public > mercurial-scm > hg-stable
diff hgext/lfs/blobstore.py @ 49726:18282cf18aa2
branching: merge stable into default
author | Rapha?l Gom?s <rgomes@octobus.net> |
---|---|
date | Mon, 14 Nov 2022 10:59:09 +0100 |
parents | 250d9c8aaf10 3556f0392808 |
children | 6543469a351e |
line wrap: on
line diff
--- a/hgext/lfs/blobstore.py Mon Nov 07 09:25:20 2022 +0100 +++ b/hgext/lfs/blobstore.py Mon Nov 14 10:59:09 2022 +0100 @@ -601,14 +601,30 @@ continue raise - # Until https multiplexing gets sorted out + # Until https multiplexing gets sorted out. It's not clear if + # ConnectionManager.set_ready() is externally synchronized for thread + # safety with Windows workers. if self.ui.configbool(b'experimental', b'lfs.worker-enable'): + # The POSIX workers are forks of this process, so before spinning + # them up, close all pooled connections. Otherwise, there's no way + # to coordinate between them about who is using what, and the + # transfers will get corrupted. + # + # TODO: add a function to keepalive.ConnectionManager to mark all + # ready connections as in use, and roll that back after the fork? + # That would allow the existing pool of connections in this process + # to be preserved. + def prefork(): + for h in self.urlopener.handlers: + getattr(h, "close_all", lambda: None)() + oids = worker.worker( self.ui, 0.1, transfer, (), sorted(objects, key=lambda o: o.get(b'oid')), + prefork=prefork, ) else: oids = transfer(sorted(objects, key=lambda o: o.get(b'oid')))