SHA256
1
0
forked from pool/salt
salt/use-threadpool-from-multiprocessing.pool-to-avoid-le.patch

48 lines
1.5 KiB
Diff

From 1f50b796dd551c25a8fc87fe825d1508f340858e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pablo=20Su=C3=A1rez=20Hern=C3=A1ndez?=
<psuarezhernandez@suse.com>
Date: Tue, 30 Apr 2019 10:51:42 +0100
Subject: [PATCH] Use ThreadPool from multiprocessing.pool to avoid
leakings
---
salt/grains/core.py | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/salt/grains/core.py b/salt/grains/core.py
index 4600f055dd..f1e3ebe9d2 100644
--- a/salt/grains/core.py
+++ b/salt/grains/core.py
@@ -27,7 +27,7 @@ import datetime
import warnings
import time
-from multiprocessing.dummy import Pool as ThreadPool
+from multiprocessing.pool import ThreadPool
# pylint: disable=import-error
try:
@@ -2300,10 +2300,14 @@ def fqdns():
# Create a ThreadPool to process the underlying calls to 'socket.gethostbyaddr' in parallel.
# This avoid blocking the execution when the "fqdn" is not defined for certains IP addresses, which was causing
# that "socket.timeout" was reached multiple times secuencially, blocking execution for several seconds.
- pool = ThreadPool(8)
- results = pool.map(_lookup_fqdn, addresses)
- pool.close()
- pool.join()
+
+ try:
+ pool = ThreadPool(8)
+ results = pool.map(_lookup_fqdn, addresses)
+ pool.close()
+ pool.join()
+ except Exception as exc:
+ log.error("Exception while creating a ThreadPool for resolving FQDNs: %s", exc)
for item in results:
if item:
--
2.16.4