From 281ccf99a4340af54823e931ee32ad8450dbc147 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Sun, 30 Jan 2022 17:24:01 +0100 Subject: Fixed an issue where SysCommand() never utilized the SysCommandWorker() context, which means SysCommandWorker() never closed the pty, hogging all system handles for it. --- archinstall/lib/general.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'archinstall') diff --git a/archinstall/lib/general.py b/archinstall/lib/general.py index 680e41cd..a3976234 100644 --- a/archinstall/lib/general.py +++ b/archinstall/lib/general.py @@ -427,13 +427,20 @@ class SysCommand: } def create_session(self) -> bool: + """ + Initiates a :ref:`SysCommandWorker` session in this class ``.session``. + It then proceeds to poll the process until it ends, after which it also + clears any printed output if ``.peak_output=True``. + """ if self.session: - return True + return self.session - self.session = SysCommandWorker(self.cmd, callbacks=self._callbacks, peak_output=self.peak_output, environment_vars=self.environment_vars) + with SysCommandWorker(self.cmd, callbacks=self._callbacks, peak_output=self.peak_output, environment_vars=self.environment_vars) as session: + if not self.session: + self.session = session - while self.session.ended is None: - self.session.poll() + while self.session.ended is None: + self.session.poll() if self.peak_output: sys.stdout.write('\n') -- cgit v1.2.3-70-g09d2