Skip to content

Commit 7301584

Browse files
committed
Always call wait() on subprocesses before closing stdout/stderr streams
Fixes (detected by python 3.6): Exception ignored in: <bound method Popen.__del__ of <subprocess.Popen object at 0x105075128>> Traceback (most recent call last): File "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 761, in __del__ ResourceWarning, source=self) ResourceWarning: subprocess 83285 is still running
1 parent 898e601 commit 7301584

File tree

4 files changed

+10
-0
lines changed

4 files changed

+10
-0
lines changed

pygccxml/parser/config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,7 @@ def create_compiler_path(xml_generator, compiler_path):
443443
stdout=subprocess.PIPE,
444444
stderr=subprocess.PIPE)
445445
compiler_path = p.stdout.read().decode("utf-8").rstrip()
446+
p.wait()
446447
p.stdout.close()
447448
p.stderr.close()
448449
# No mscv found; look for mingw
@@ -452,6 +453,7 @@ def create_compiler_path(xml_generator, compiler_path):
452453
stdout=subprocess.PIPE,
453454
stderr=subprocess.PIPE)
454455
compiler_path = p.stdout.read().decode("utf-8").rstrip()
456+
p.wait()
455457
p.stdout.close()
456458
p.stderr.close()
457459
else:
@@ -462,6 +464,7 @@ def create_compiler_path(xml_generator, compiler_path):
462464
stdout=subprocess.PIPE,
463465
stderr=subprocess.PIPE)
464466
compiler_path = p.stdout.read().decode("utf-8").rstrip()
467+
p.wait()
465468
p.stdout.close()
466469
p.stderr.close()
467470
# No clang found; use gcc
@@ -471,6 +474,7 @@ def create_compiler_path(xml_generator, compiler_path):
471474
stdout=subprocess.PIPE,
472475
stderr=subprocess.PIPE)
473476
compiler_path = p.stdout.read().decode("utf-8").rstrip()
477+
p.wait()
474478
p.stdout.close()
475479
p.stderr.close()
476480

pygccxml/parser/source_reader.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ def __create_command_line(self, source_file, xml_file):
122122
stdout=subprocess.PIPE,
123123
stderr=subprocess.PIPE)
124124
help = p.stdout.read().decode("utf-8")
125+
p.wait()
125126
p.stdout.close()
126127
p.stderr.close()
127128
if "CastXML wrapper" in help:
@@ -349,6 +350,7 @@ def create_xml_file(self, source_file, destination=None):
349350
utils.remove_file_no_raise(xml_file, self.__config)
350351
raise
351352
finally:
353+
process.wait()
352354
process.stdout.close()
353355
return xml_file
354356

pygccxml/utils/utils.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,19 +53,22 @@ def find_xml_generator(name=None):
5353
p = subprocess.Popen([command, name], stdout=subprocess.PIPE,
5454
stderr=subprocess.PIPE)
5555
path = p.stdout.read().decode("utf-8")
56+
p.wait()
5657
p.stdout.close()
5758
p.stderr.close()
5859
if path == "":
5960
name = "gccxml"
6061
p = subprocess.Popen([command, name], stdout=subprocess.PIPE,
6162
stderr=subprocess.PIPE)
6263
path = p.stdout.read().decode("utf-8")
64+
p.wait()
6365
p.stdout.close()
6466
p.stderr.close()
6567
else:
6668
p = subprocess.Popen([command, name], stdout=subprocess.PIPE,
6769
stderr=subprocess.PIPE)
6870
path = p.stdout.read().decode("utf-8")
71+
p.wait()
6972
p.stdout.close()
7073
p.stderr.close()
7174
if path == "":

unittests/file_cache_tester.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ def test_reopen_cache():
101101
stdout=subprocess.PIPE,
102102
env=env)
103103
print(p.stdout.read())
104+
p.wait()
104105
p.stdout.close()
105106

106107

0 commit comments

Comments
 (0)