Skip to content

Commit 6f45a5a

Browse files
committed
Handle more ResourceWarning issues.
admin.py - remove unneeded close. mailer.py - close debug log file. indexer.py - close read of version file memorydb.py - close python files being compled. Similiar to instance. not sure why it's compoing things and not just letting instance do it. .travis.ymv disable all except 3.9-dev till we get a handle on errors. also increase errors to 50 from 20.
1 parent 2bf8c73 commit 6f45a5a

File tree

5 files changed

+20
-13
lines changed

5 files changed

+20
-13
lines changed

.travis.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ language: python
55
cache: pip
66

77
python:
8-
- 2.7
8+
# - 2.7
99
- 3.9-dev
10-
- 3.8
11-
- 3.7
12-
- 3.6
13-
- 3.4
14-
- nightly
10+
# - 3.8
11+
# - 3.7
12+
# - 3.6
13+
# - 3.4
14+
# - nightly
1515

1616

1717
#I would like to build and test the maint-1.6 and trunk/default
@@ -153,7 +153,7 @@ script:
153153
-W "ignore:'U' mode::docutils.io"
154154
-W "ignore:unclosed:ResourceWarning:roundup.roundup.demo"
155155
-W "ignore:unclosed file:ResourceWarning:enum"
156-
-v --maxfail=20 test/ --cov=roundup
156+
-v --maxfail=50 test/ --cov=roundup
157157

158158
after_success:
159159
- codecov

roundup/admin.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1367,7 +1367,6 @@ class colon_separated(csv.excel):
13671367
if max_len > self.db.config.CSV_FIELD_SIZE:
13681368
print("Warning: config csv_field_size should be at least %s" %
13691369
max_len, file=sys.stderr)
1370-
jf.close()
13711370
return 0
13721371

13731372
def do_exporttables(self, args):

roundup/backends/indexer_dbm.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ def __init__(self, db):
5151
# for now the file itself is a flag
5252
self.force_reindex()
5353
elif os.path.exists(version):
54-
version = open(version).read()
54+
fd = open(version)
55+
version = fd.read()
56+
fd.close()
5557
# check the value and reindex if it's not the latest
5658
if version.strip() != '1':
5759
self.force_reindex()
@@ -63,7 +65,9 @@ def force_reindex(self):
6365
shutil.rmtree(self.indexdb_path)
6466
os.makedirs(self.indexdb_path)
6567
os.chmod(self.indexdb_path, 0o775) # nosec - allow group write
66-
open(os.path.join(self.indexdb_path, 'version'), 'w').write('1\n')
68+
fd = open(os.path.join(self.indexdb_path, 'version'), 'w')
69+
fd.write('1\n')
70+
fd.close()
6771
self.reindex = 1
6872
self.changed = 1
6973

@@ -260,6 +264,7 @@ def save_index(self):
260264
filename = self.indexdb + initchar
261265
pickle_fh = open(filename, 'wb')
262266
pickle_fh.write(zlib.compress(pickle_str))
267+
pickle_fh.close()
263268
os.chmod(filename, 0o664)
264269

265270
# save done

roundup/mailer.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,9 +278,11 @@ def smtp_send(self, to, message, sender=None):
278278
# that resulting file can be openened in a mailer
279279
fmt = '%a %b %m %H:%M:%S %Y'
280280
unixfrm = 'From %s %s' % (sender, Date('.').pretty(fmt))
281-
open(self.debug, 'a').write('%s\nFROM: %s\nTO: %s\n%s\n\n' %
281+
debug_fh = open(self.debug, 'a')
282+
debug_fh.write('%s\nFROM: %s\nTO: %s\n%s\n\n' %
282283
(unixfrm, sender,
283284
', '.join(to), message))
285+
debug_fh.close()
284286
else:
285287
# now try to send the message
286288
try:

roundup/test/memorydb.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,9 @@ def create(journaltag, create=True, debug=False, prefix=default_prefix):
6363
for fn in os.listdir(dirname):
6464
if not fn.endswith('.py'): continue
6565
vars = {}
66-
exec(compile(open(os.path.join(dirname, fn)).read(),
67-
os.path.join(dirname, fn), 'exec'), vars)
66+
with open(os.path.join(dirname, fn)) as fd:
67+
exec(compile(fd.read(),
68+
os.path.join(dirname, fn), 'exec'), vars)
6869
vars['init'](db)
6970

7071
tx_Source_init(db)

0 commit comments

Comments
 (0)