Re:
- From
René Scharfe <l.s.r@web.de>
- Date
- Feb 27, 2018, 10:26 UTC
- Message-ID
- <d842741d-c079-3222-3655-cdd426ff0516@web.de>
- In-Reply-To
- <CAJTBYTnA56peLi4Cb0ZEx1PtOmh8eRF45tQgE=prwF_o7FDMcA@mail.gmail.com>
Am 27.02.2018 um 02:18 schrieb Alan Gage:
Show 9 quoted lines
> Hello, I recently noticed a bug involving GitBash and Python. I was > running a function that would post the system time once every second > using a while loop but the text was only sent after the while loop > ended due to a timer I had set. Essesntially, instead of it being > entered every second into the terminal, it was entered all at once, > when the loop ended. I tried this with the Command Line, among other > things, and it worked as intended, with the text being entered every > second. This is on Windows 10 Pro with the Fall Creators Update and > the most recent version of GitBash.
Python buffers its output by default. On terminals it enables line buffering, i.e. the accumulated output is flushed when a newline character is reached. Otherwise it uses a system-dependent buffer size in the range of a few kilobytes. You can check if your output is a terminal e.g. with:
python -c "import sys; print(sys.stdout.isatty())"
You can disable buffering by running your script with "python -u". This discussion mentions more options:
https://stackoverflow.com/questions/107705/disable-output-buffering
You can also start bash on the command line. I do wonder why Git CMD seems to be started in what passes as a terminal, while Git BASH is not, though.
You may want to check out https://gitforwindows.org/ and report your findings using their issue tracker.
(This mailing list here, git@vger.kernel.org, is mostly used for discussing Git itself, not so much about extra tools like bash or Python that are packaged with Git for Windows.)
René