Fixed an issue where SysCommand() never utilized the SysCommandWorker() context, which means SysCommandWorker() never closed the pty, hogging all system handles for it.
This commit is contained in:
parent
179c103cdd
commit
281ccf99a4
|
|
@ -427,13 +427,20 @@ class SysCommand:
|
||||||
}
|
}
|
||||||
|
|
||||||
def create_session(self) -> bool:
|
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:
|
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:
|
while self.session.ended is None:
|
||||||
self.session.poll()
|
self.session.poll()
|
||||||
|
|
||||||
if self.peak_output:
|
if self.peak_output:
|
||||||
sys.stdout.write('\n')
|
sys.stdout.write('\n')
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue