Skip to content

Commit

Permalink
Exit fetcher processes to prevent their connections leaking.
Browse files Browse the repository at this point in the history
  • Loading branch information
SSheldon committed Jan 16, 2016
1 parent 05fc0c1 commit 47125f3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions coldsweat/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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()

Expand Down

0 comments on commit 47125f3

Please sign in to comment.