Skip to content

Commit e860527

Browse files
committed
fix unclosed subprocess files
1 parent 08dd208 commit e860527

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

GSASII/nistlat.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,8 @@ def ReduceCell(center, cellin, mode=0, deltaV=0, output=None):
187187
print(line)
188188
return celldict
189189
finally:
190+
p.stdout.close()
191+
p.stderr.close()
190192
p.terminate()
191193
if len(celldict['output']) == 0 or len(err) > 0:
192194
print('Error:' ,err.decode())
@@ -252,6 +254,8 @@ def ConvCell(redcell):
252254
return None
253255
#return cell
254256
finally:
257+
p.stdout.close()
258+
p.stderr.close()
255259
p.terminate()
256260
if len(err) > 0:
257261
print('Error:' ,err.decode())
@@ -320,6 +324,8 @@ def CompareCell(cell1, center1, cell2, center2, tolerance=3*[0.2]+3*[1],
320324
if output: fp = open(output,'w')
321325
# read output and parse
322326
lines = [b.decode() for b in p.stdout.readlines()]
327+
p.stdout.close()
328+
p.stderr.close()
323329
p.terminate()
324330
if fp:
325331
for line in lines: _emulateLP(line,fp)
@@ -440,6 +446,8 @@ def CellSymSearch(cellin, center, tolerance=3*[0.2]+3*[1], mode=0,
440446

441447
d = 1
442448
lines = [b.decode() for b in p.stdout.readlines()]
449+
p.stdout.close()
450+
p.stderr.close()
443451
p.terminate()
444452
fp = None
445453
if output: fp = open(output,'w')
@@ -562,8 +570,10 @@ def CellSymSearch(cellin, center, tolerance=3*[0.2]+3*[1], mode=0,
562570
print('CellSymSearch parse error at line ',lnum,'\nNote error:',msg)
563571
print(line)
564572
return celldict
565-
finally:
566-
p.terminate()
573+
# finally:
574+
# p.stdout.close()
575+
# p.stderr.close()
576+
# p.terminate()
567577
if len(symCellList) == 0 or len(err) > 0:
568578
print('Error:' ,err.decode())
569579
return symCellList

0 commit comments

Comments
 (0)