Use a deque to avoid keeping all the scanned files alive

Avoid keeping all the files that have been read and scanned
in memory by use a deque and popping files off after they
have been read (this allows the gc to clean them up).
This commit is contained in:
Joshua Harlow 2014-05-18 20:31:07 -07:00
parent 1a6a4658b4
commit e050803234
1 changed files with 4 additions and 2 deletions

View File

@ -31,6 +31,7 @@ What is checked:
"""
import argparse
import collections
import os
from six.moves import configparser
@ -140,13 +141,14 @@ def main():
args['ignore'].update(cfg.pop("ignore", set()))
args.update(cfg)
files = []
files = collections.deque()
for filename in utils.find_files(args.pop('paths', []), FILE_PATTERNS):
files.append(file_parser.parse(filename))
ignoreables = frozenset(args.pop('ignore', []))
errors = 0
for f in files:
while files:
f = files.popleft()
for c in fetch_checks(args):
try:
reports = set(c.REPORTS)