From 1123b0dc80eeea1d1a77827a1b63ec319c2bd28b Mon Sep 17 00:00:00 2001 From: Ralph Bean Date: Mon, 1 Jun 2015 19:41:45 +0000 Subject: [PATCH] Try again to squash memory leak in fedmsg-map. --- .../fedmsg-activation/files/fedmsg-map.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/roles/collectd/fedmsg-activation/files/fedmsg-map.py b/roles/collectd/fedmsg-activation/files/fedmsg-map.py index 42c97b2a51..ccf6ea9d86 100644 --- a/roles/collectd/fedmsg-activation/files/fedmsg-map.py +++ b/roles/collectd/fedmsg-activation/files/fedmsg-map.py @@ -22,8 +22,6 @@ for_collectd = 'verbose' not in sys.argv active = collections.defaultdict(list) inactive = collections.defaultdict(list) -pool = multiprocessing.pool.ThreadPool(25) - def info(content="\n"): if not for_collectd: sys.stdout.write(content) @@ -53,10 +51,24 @@ def scan_one(item): def scan_all(): + global active + global inactive + + del active + del inactive + + active = collections.defaultdict(list) + inactive = collections.defaultdict(list) + items = [(name, addr) for name, endpoints in config['endpoints'].items() for addr in endpoints] + + # There is likely overhead in creating and destroying this thing, but we have + # memory leaks to track down. + pool = multiprocessing.pool.ThreadPool(25) pool.map(scan_one, items) + pool.close() info() @@ -129,5 +141,3 @@ else: print(output) if interval - delta > 0: time.sleep(interval - delta) - -pool.close()