Merge pull request 'refs #2776 Fix EOF bug in interfaceAdm()' (#62) from interfaceadm into main
ogagent/pipeline/tag There was a failure building this commit Details

Reviewed-on: #62
pull/63/head 8.3.1
Natalia Serrano 2025-09-11 16:35:46 +02:00
commit d945d8566e
3 changed files with 23 additions and 12 deletions

View File

@ -6,6 +6,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [8.3.1] - 2025-09-11
### Fixed
- Fix EOF bug in interfaceAdm()
## [8.3.0] - 2025-08-29
### Changed

View File

@ -1 +1 @@
8.0.0
8.3.1

View File

@ -266,12 +266,9 @@ class ogLiveWorker(ServerWorker):
def interfaceAdmin (self, method, parametros=[]):
if method not in ['ConsolaRemota', 'procesaCache']:
## python
logger.debug (f'({method}) is a python method')
exe = '{}/{}'.format (self.pathinterface, method)
proc = [exe]+parametros
else:
## bash
logger.debug (f'({method}) is a bash method')
exe = '{}/{}'.format (self.pathinterface, method)
@ -297,31 +294,38 @@ class ogLiveWorker(ServerWorker):
#logger.debug ('no queue--not writing any PID to it')
pass
sout = serr = ''
finished = False
out_finished = False
err_finished = False
finished = False
buf_size = 4096
stdout_buf = bytes()
stderr_buf = bytes()
while True:
ready_to_read, _, exceptions = select.select ([p.stdout, p.stderr], [], [p.stdout, p.stderr], 0.2)
check_read = []
check_exceptions = []
if not out_finished:
check_read.append (p.stdout)
check_exceptions.append (p.stdout)
if not err_finished:
check_read.append (p.stderr)
check_exceptions.append (p.stderr)
ready_to_read, _, exceptions = select.select (check_read, [], check_exceptions, 0.2)
if p.stdout in ready_to_read:
data = p.stdout.read(buf_size)
stdout_buf = stdout_buf + data
if len(data) < buf_size:
if 0 == len(data):
out_finished = True
if p.stderr in ready_to_read:
data = p.stdout.read(buf_size)
data = p.stderr.read(buf_size)
stderr_buf = stderr_buf + data
if len(data) < buf_size:
if 0 == len(data):
err_finished = True
if p.stdout in exceptions or p.stderr in exceptions:
@ -335,12 +339,13 @@ class ogLiveWorker(ServerWorker):
sout = stdout_buf.decode('utf-8', 'ignore').strip()
serr = stdout_buf.decode('utf-8', 'ignore').strip()
serr = stderr_buf.decode('utf-8', 'ignore').strip()
try:
p.wait (0.1)
finished = True
except subprocess.TimeoutExpired:
## BUG: dejamos un zombie colgando
pass