pyosal 0.2.0__tar.gz → 0.2.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pyosal-0.2.0/src/pyosal.egg-info → pyosal-0.2.1}/PKG-INFO +1 -1
- {pyosal-0.2.0 → pyosal-0.2.1}/pyproject.toml +1 -1
- {pyosal-0.2.0 → pyosal-0.2.1}/src/pyosal/constants_version.py +1 -1
- {pyosal-0.2.0 → pyosal-0.2.1}/src/pyosal/pyosal.py +23 -19
- {pyosal-0.2.0 → pyosal-0.2.1/src/pyosal.egg-info}/PKG-INFO +1 -1
- {pyosal-0.2.0 → pyosal-0.2.1}/LICENSE.txt +0 -0
- {pyosal-0.2.0 → pyosal-0.2.1}/MANIFEST.in +0 -0
- {pyosal-0.2.0 → pyosal-0.2.1}/README.md +0 -0
- {pyosal-0.2.0 → pyosal-0.2.1}/setup.cfg +0 -0
- {pyosal-0.2.0 → pyosal-0.2.1}/src/pyosal/__init__.py +0 -0
- {pyosal-0.2.0 → pyosal-0.2.1}/src/pyosal/constants.py +0 -0
- {pyosal-0.2.0 → pyosal-0.2.1}/src/pyosal.egg-info/SOURCES.txt +0 -0
- {pyosal-0.2.0 → pyosal-0.2.1}/src/pyosal.egg-info/dependency_links.txt +0 -0
- {pyosal-0.2.0 → pyosal-0.2.1}/src/pyosal.egg-info/requires.txt +0 -0
- {pyosal-0.2.0 → pyosal-0.2.1}/src/pyosal.egg-info/top_level.txt +0 -0
|
@@ -273,6 +273,7 @@ class PyOsal(metaclass=_PyOsalMeta):
|
|
|
273
273
|
# Run your existing function in a background thread
|
|
274
274
|
shared_container = {}
|
|
275
275
|
t = threading.Thread(target=self.run_cmd, args=(cmd, working_dir, use_raw_log, log_file, print_cb, env, quiet, shared_container))
|
|
276
|
+
t.daemon = True
|
|
276
277
|
t.start()
|
|
277
278
|
|
|
278
279
|
# Wait briefly for the subprocess to actually initialize and populate the container
|
|
@@ -301,7 +302,7 @@ class PyOsal(metaclass=_PyOsalMeta):
|
|
|
301
302
|
timed_out = True
|
|
302
303
|
rc = 0 # override rc since timeout is expected
|
|
303
304
|
|
|
304
|
-
t.join()
|
|
305
|
+
t.join(timeout=0.25)
|
|
305
306
|
rc_str = f'rc={rc}'
|
|
306
307
|
if shared_container['proc'] is None:
|
|
307
308
|
sys.stdout.write(f'[timeout] {rc_str: <6} process ended due to exception\n')
|
|
@@ -326,7 +327,7 @@ class PyOsal(metaclass=_PyOsalMeta):
|
|
|
326
327
|
try:
|
|
327
328
|
rc = self._kill_process_tree(shared_container, 'terminate')
|
|
328
329
|
rc_str = f'rc={rc}'
|
|
329
|
-
|
|
330
|
+
sys.stdout.write(f'[timeout] {rc_str: <6} process terminated gracefully\n')
|
|
330
331
|
except subprocess.TimeoutExpired:
|
|
331
332
|
sys.stdout.write('[timeout] process did not terminate, killing process...\n')
|
|
332
333
|
sys.stdout.flush()
|
|
@@ -457,16 +458,20 @@ class PyOsal(metaclass=_PyOsalMeta):
|
|
|
457
458
|
def _kill_alt_process_tree(self, shared_container):
|
|
458
459
|
rc = 0
|
|
459
460
|
print(f'[timeout] {self.os_name} detected...')
|
|
460
|
-
if '
|
|
461
|
-
cmd_str = ' '.join(shared_container['cmd']
|
|
461
|
+
if 'timed' in self._debug:
|
|
462
|
+
cmd_str = ' '.join(shared_container['cmd'])
|
|
462
463
|
print(f'pyosal._kill_alt_process_tree: pids={shared_container["pids"]} cmd="{cmd_str}"')
|
|
463
464
|
|
|
464
465
|
for pid in shared_container['pids']:
|
|
465
466
|
if not psutil.pid_exists(pid):
|
|
467
|
+
if 'timed' in self._debug:
|
|
468
|
+
print(f'pyosal._kill_alt_process_tree: pid={pid} does not exist')
|
|
466
469
|
continue
|
|
467
470
|
proc = psutil.Process(pid)
|
|
468
471
|
# terminate does not work in windows
|
|
469
472
|
proc.kill()
|
|
473
|
+
if 'timed' in self._debug:
|
|
474
|
+
print(f'pyosal._kill_alt_process_tree: pid={pid} killed')
|
|
470
475
|
time.sleep(0.010)
|
|
471
476
|
return rc
|
|
472
477
|
|
|
@@ -585,7 +590,6 @@ class PyOsal(metaclass=_PyOsalMeta):
|
|
|
585
590
|
universal_newlines=True,
|
|
586
591
|
errors='replace',
|
|
587
592
|
text=True,
|
|
588
|
-
# stdin=subprocess.DEVNULL,
|
|
589
593
|
stdin=None,
|
|
590
594
|
stdout=subprocess.PIPE,
|
|
591
595
|
stderr=subprocess.STDOUT,
|
|
@@ -612,30 +616,31 @@ class PyOsal(metaclass=_PyOsalMeta):
|
|
|
612
616
|
shared_container['state'] = 'cmd-not-found'
|
|
613
617
|
|
|
614
618
|
# buffer contains the current set of bytes read from proc.stdout so far
|
|
615
|
-
buffer =
|
|
619
|
+
buffer = ''
|
|
616
620
|
while True:
|
|
617
|
-
|
|
618
|
-
if not
|
|
621
|
+
char = proc.stdout.read(1)
|
|
622
|
+
if not char:
|
|
623
|
+
# it's ''
|
|
619
624
|
break
|
|
620
625
|
|
|
621
626
|
# append the current chunk
|
|
622
627
|
# Some apps use linefeeds to do "progress" lines (e.g. 10% 11% etc), so replace any linefeeds with nothing
|
|
623
|
-
|
|
628
|
+
if char == '\r':
|
|
629
|
+
char = '\n'
|
|
624
630
|
|
|
625
|
-
|
|
626
|
-
|
|
631
|
+
buffer += char
|
|
632
|
+
|
|
633
|
+
# if there is a newline in the buffer, then we have at least a full line of characters
|
|
634
|
+
if '\n' not in buffer:
|
|
627
635
|
continue
|
|
628
636
|
|
|
629
637
|
# split the buffer at the newline(s)
|
|
630
|
-
buff_lines = buffer.split(
|
|
638
|
+
buff_lines = buffer.split('\n')
|
|
631
639
|
# save the remaining bytes in buffer
|
|
632
640
|
buffer = buff_lines.pop()
|
|
633
641
|
|
|
634
642
|
# at this point buff_lines contains one or more lines (as bytes)
|
|
635
|
-
for
|
|
636
|
-
# convert the bytes to UTF-8 chars
|
|
637
|
-
line = line_bytes.decode('utf-8', errors='replace')
|
|
638
|
-
|
|
643
|
+
for line in buff_lines:
|
|
639
644
|
if 'run' in self._debug:
|
|
640
645
|
if not line.isprintable():
|
|
641
646
|
sys.stdout.write('has hex: ' + ascii(line) + '\n')
|
|
@@ -668,10 +673,9 @@ class PyOsal(metaclass=_PyOsalMeta):
|
|
|
668
673
|
|
|
669
674
|
# at this point: chunk was empty
|
|
670
675
|
if len(buffer) > 0:
|
|
671
|
-
|
|
672
|
-
for
|
|
676
|
+
lines = buffer.split('\n')
|
|
677
|
+
for line in lines:
|
|
673
678
|
lineno += 1
|
|
674
|
-
line = line_bytes.decode('utf-8', errors='replace')
|
|
675
679
|
self._save_line(line, lineno, lines, fp, print_cb, use_raw_log, quiet)
|
|
676
680
|
|
|
677
681
|
if fp:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|