Merge "Parallelize static resource cleanup"
This commit is contained in:
commit
e607bc7c00
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user