From 47125f37d34c0bf553f1fa5173ef2ff7fa2afac9 Mon Sep 17 00:00:00 2001 From: Steven Sheldon Date: Wed, 13 Jan 2016 00:44:47 -0800 Subject: [PATCH] Exit fetcher processes to prevent their connections leaking. --- coldsweat/controllers.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/coldsweat/controllers.py b/coldsweat/controllers.py index 69afa99..312cb18 100644 --- a/coldsweat/controllers.py +++ b/coldsweat/controllers.py @@ -271,8 +271,11 @@ def fetch_feeds(self, feeds): if config.fetcher.processes: from multiprocessing import Pool - p = Pool(config.fetcher.processes) + # Each worker has its own connection + p = Pool(config.fetcher.processes, initializer=connect) p.map(feed_worker, feeds) + # Exit the worker processes so their connections do not leak + p.close() else: # Just sequence requests in this process for feed in feeds: @@ -299,9 +302,6 @@ def fetch_all_feeds(self): def feed_worker(feed): - - # Each worker has its own connection - connect() fetcher = Fetcher(feed) fetcher.update_feed()