Skip to content

Commit 9b24316

Browse files
committed
plugin: _execute_commands_in_subprocess: make sure pipes get closed
1 parent ddaa204 commit 9b24316

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

electrum/plugin.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -338,15 +338,15 @@ def _execute_commands_in_subprocess(commands: List[str]) -> None:
338338
Executes the given commands in a subprocess and asserts that it was successful.
339339
"""
340340
import subprocess
341-
process = subprocess.Popen(
341+
with subprocess.Popen(
342342
commands,
343343
stdout=subprocess.PIPE,
344344
stderr=subprocess.PIPE,
345-
text=True
346-
)
347-
stdout, stderr = process.communicate()
348-
if process.returncode != 0:
349-
raise Exception(f'error executing command ({process.returncode}): {stderr}')
345+
text=True,
346+
) as process:
347+
stdout, stderr = process.communicate()
348+
if process.returncode != 0:
349+
raise Exception(f'error executing command ({process.returncode}): {stderr}')
350350

351351
def _write_key_to_root_file_linux(self, key_hex: str) -> None:
352352
"""

0 commit comments

Comments
 (0)