mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-27 20:14:27 +01:00
run: try to overcome run BlockingIOError
This commit is contained in:
@@ -397,6 +397,7 @@ def run_cmd(
|
|||||||
# Ignoring the exception is not enough as it prints a warning anyways.
|
# Ignoring the exception is not enough as it prints a warning anyways.
|
||||||
#sigpipe_old = signal.getsignal(signal.SIGPIPE)
|
#sigpipe_old = signal.getsignal(signal.SIGPIPE)
|
||||||
#signal.signal(signal.SIGPIPE, signal.SIG_DFL)
|
#signal.signal(signal.SIGPIPE, signal.SIG_DFL)
|
||||||
|
|
||||||
# https://stackoverflow.com/questions/15535240/python-popen-write-to-stdout-and-log-file-simultaneously/52090802#52090802
|
# https://stackoverflow.com/questions/15535240/python-popen-write-to-stdout-and-log-file-simultaneously/52090802#52090802
|
||||||
with subprocess.Popen(cmd, stdout=stdout, stderr=stderr, env=env, **kwargs) as proc:
|
with subprocess.Popen(cmd, stdout=stdout, stderr=stderr, env=env, **kwargs) as proc:
|
||||||
if out_file is not None:
|
if out_file is not None:
|
||||||
@@ -407,7 +408,11 @@ def run_cmd(
|
|||||||
if byte:
|
if byte:
|
||||||
if show_stdout:
|
if show_stdout:
|
||||||
sys.stdout.buffer.write(byte)
|
sys.stdout.buffer.write(byte)
|
||||||
sys.stdout.flush()
|
try:
|
||||||
|
sys.stdout.flush()
|
||||||
|
except BlockingIOError:
|
||||||
|
# TODO understand. Why, Python, why.
|
||||||
|
pass
|
||||||
logfile.write(byte)
|
logfile.write(byte)
|
||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
|
|||||||
Reference in New Issue
Block a user