mirror of
https://github.com/openSUSE/osc.git
synced 2024-12-25 17:36:13 +01:00
changed commit 22b272f3af
a bit
- only "fix" sys.stdout if it is no tty - make sys.stdout line buffered (to avoid too "many" write calls) - added more detailed explanation why this is needed
This commit is contained in:
parent
22b272f3af
commit
56a9ab60dc
@ -23,8 +23,18 @@ except NameError:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
# avoid buffering output on pipes (bnc#930137)
|
# avoid buffering output on pipes (bnc#930137)
|
||||||
if sys.stdout.name == '<stdout>':
|
# Basically, a "print('foo')" call is translated to a corresponding
|
||||||
sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)
|
# fwrite call that writes to the stdout stream (cf. string_print
|
||||||
|
# (Objects/stringobject.c) and builtin_print (Python/bltinmodule.c));
|
||||||
|
# If no pipe is used, stdout is a tty/refers to a terminal =>
|
||||||
|
# the stream is line buffered (see _IO_file_doallocate (libio/filedoalloc.c)).
|
||||||
|
# If a pipe is used, stdout does not refer to a terminal anymore =>
|
||||||
|
# the stream is fully buffered by default (see _IO_file_doallocate).
|
||||||
|
# The following fdopen call makes stdout line buffered again (at least on
|
||||||
|
# systems that support setvbuf - if setvbuf is not supported, the stream
|
||||||
|
# remains fully buffered (see PyFile_SetBufSize (Objects/fileobject.c))).
|
||||||
|
if not os.isatty(sys.stdout.fileno()):
|
||||||
|
sys.stdout = os.fdopen(sys.stdout.fileno(), sys.stdout.mode, 1)
|
||||||
|
|
||||||
osccli = commandline.Osc()
|
osccli = commandline.Osc()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user