Merge "Parallelize static resource cleanup"

This commit is contained in:
Zuul 2024-10-15 10:07:28 +00:00 committed by Gerrit Code Review
commit e607bc7c00

View File

@ -443,19 +443,26 @@ class StaticNodeProvider(Provider, QuotaSupport):
def cleanupLeakedResources(self):
if self._idle:
return
with self._register_lock:
self.getRegisteredNodes()
for pool in self.provider.pools.values():
for static_node in pool.nodes:
try:
self.syncNodeCount(static_node, pool)
except StaticNodeError as exc:
self.log.warning("Couldn't sync node: %s", exc)
continue
except Exception:
self.log.exception("Couldn't sync node %s:",
nodeTuple(static_node))
continue
with ThreadPoolExecutor() as executor:
for pool in self.provider.pools.values():
synced_nodes = []
for static_node in pool.nodes:
synced_nodes.append((static_node, executor.submit(
self.syncNodeCount, static_node, pool)))
for static_node, result in synced_nodes:
try:
result.result()
except StaticNodeError as exc:
self.log.warning("Couldn't sync node: %s", exc)
continue
except Exception:
self.log.exception("Couldn't sync node %s:",
nodeTuple(static_node))
continue
def getRequestHandler(self, poolworker, request):
return StaticNodeRequestHandler(poolworker, request)