2020-04-07 14:14:01 +02:00
|
|
|
From 1f50b796dd551c25a8fc87fe825d1508f340858e Mon Sep 17 00:00:00 2001
|
2019-04-30 14:10:21 +02:00
|
|
|
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
|
2020-04-07 14:14:01 +02:00
|
|
|
index 4600f055dd..f1e3ebe9d2 100644
|
2019-04-30 14:10:21 +02:00
|
|
|
--- a/salt/grains/core.py
|
|
|
|
+++ b/salt/grains/core.py
|
2019-11-28 16:41:55 +01:00
|
|
|
@@ -27,7 +27,7 @@ import datetime
|
2019-04-30 14:10:21 +02:00
|
|
|
import warnings
|
2019-11-28 16:41:55 +01:00
|
|
|
import time
|
2019-04-30 14:10:21 +02:00
|
|
|
|
|
|
|
-from multiprocessing.dummy import Pool as ThreadPool
|
|
|
|
+from multiprocessing.pool import ThreadPool
|
|
|
|
|
|
|
|
# pylint: disable=import-error
|
|
|
|
try:
|
2020-04-07 14:14:01 +02:00
|
|
|
@@ -2300,10 +2300,14 @@ def fqdns():
|
2019-04-30 14:10:21 +02:00
|
|
|
# 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:
|
|
|
|
--
|
2019-11-28 16:41:55 +01:00
|
|
|
2.16.4
|
2019-04-30 14:10:21 +02:00
|
|
|
|
|
|
|
|