commit python-yaspin for openSUSE:Factory
Hello community, here is the log from the commit of package python-yaspin for openSUSE:Factory checked in at 2019-05-27 08:30:52 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-yaspin (Old) and /work/SRC/openSUSE:Factory/.python-yaspin.new.5148 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "python-yaspin" Mon May 27 08:30:52 2019 rev:3 rq:705257 version:0.14.3 Changes: -------- --- /work/SRC/openSUSE:Factory/python-yaspin/python-yaspin.changes 2019-05-06 21:17:29.769110931 +0200 +++ /work/SRC/openSUSE:Factory/.python-yaspin.new.5148/python-yaspin.changes 2019-05-27 08:30:53.655246191 +0200 @@ -1,0 +2,6 @@ +Fri May 24 13:43:28 UTC 2019 - Tomáš Chvátal <tchvatal@suse.com> + +- Update to 0.14.3: + * fix(#29): race condition between spinner thread and write() + +------------------------------------------------------------------- Old: ---- yaspin-0.14.2.tar.gz New: ---- yaspin-0.14.3.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-yaspin.spec ++++++ --- /var/tmp/diff_new_pack.XNTwsZ/_old 2019-05-27 08:30:54.367245913 +0200 +++ /var/tmp/diff_new_pack.XNTwsZ/_new 2019-05-27 08:30:54.371245912 +0200 @@ -18,7 +18,7 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-yaspin -Version: 0.14.2 +Version: 0.14.3 Release: 0 Summary: Yet Another Terminal Spinner License: MIT ++++++ yaspin-0.14.2.tar.gz -> yaspin-0.14.3.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yaspin-0.14.2/HISTORY.rst new/yaspin-0.14.3/HISTORY.rst --- old/yaspin-0.14.2/HISTORY.rst 2019-04-27 23:05:29.000000000 +0200 +++ new/yaspin-0.14.3/HISTORY.rst 2019-05-12 15:28:48.000000000 +0200 @@ -1,6 +1,12 @@ Release History =============== +0.14.3 / 2019-05-12 +------------------- + +* fix(#29): race condition between spinner thread and ``write()`` + + 0.14.2 / 2019-04-27 ------------------- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yaspin-0.14.2/PKG-INFO new/yaspin-0.14.3/PKG-INFO --- old/yaspin-0.14.2/PKG-INFO 2019-04-27 23:11:40.000000000 +0200 +++ new/yaspin-0.14.3/PKG-INFO 2019-05-12 15:31:30.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: yaspin -Version: 0.14.2 +Version: 0.14.3 Summary: Yet Another Terminal Spinner Home-page: https://github.com/pavdmyt/yaspin Author: Pavlo Dmytrenko diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yaspin-0.14.2/setup.cfg new/yaspin-0.14.3/setup.cfg --- old/yaspin-0.14.2/setup.cfg 2019-04-27 23:11:40.000000000 +0200 +++ new/yaspin-0.14.3/setup.cfg 2019-05-12 15:31:30.000000000 +0200 @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.14.2 +current_version = 0.14.3 [metadata] description-file = README.rst diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yaspin-0.14.2/tests/test_in_out.py new/yaspin-0.14.3/tests/test_in_out.py --- old/yaspin-0.14.2/tests/test_in_out.py 2019-04-27 22:31:42.000000000 +0200 +++ new/yaspin-0.14.3/tests/test_in_out.py 2019-05-12 15:28:48.000000000 +0200 @@ -8,7 +8,9 @@ And all output data is converted to builtin str type. """ +import re import sys +import time import pytest @@ -159,3 +161,22 @@ # ensure that text was cleared before resuming the spinner assert out[:4] == "\r\033[K" + + +def test_spinner_write_race_condition(capsys): + # test that spinner text does not overwrite write() contents + # this generally happens when the spinner thread writes + # between write()'s \r and the text it actually wants to write + + sp = yaspin(text="aaaa") + sp.start() + sp._interval = 0.0 + start_time = time.time() + while time.time() - start_time < 3.0: + sp.write("bbbb") + sp.stop() + + out, _ = capsys.readouterr() + assert "aaaa" in out # spinner text is present + assert "bbbb" in out # write() text is present + assert not re.search(r"aaaa[^\rb]*bbbb", out) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yaspin-0.14.2/yaspin/__version__.py new/yaspin-0.14.3/yaspin/__version__.py --- old/yaspin-0.14.2/yaspin/__version__.py 2019-04-27 23:05:29.000000000 +0200 +++ new/yaspin-0.14.3/yaspin/__version__.py 2019-05-12 15:28:48.000000000 +0200 @@ -1 +1 @@ -__version__ = "0.14.2" +__version__ = "0.14.3" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yaspin-0.14.2/yaspin/core.py new/yaspin-0.14.3/yaspin/core.py --- old/yaspin-0.14.2/yaspin/core.py 2019-04-27 23:05:29.000000000 +0200 +++ new/yaspin-0.14.3/yaspin/core.py 2019-05-12 15:28:48.000000000 +0200 @@ -76,6 +76,7 @@ self._hide_spin = None self._spin_thread = None self._last_frame = None + self._stdout_lock = threading.Lock() # Signals @@ -247,43 +248,47 @@ thr_is_alive = self._spin_thread and self._spin_thread.is_alive() if thr_is_alive and not self._hide_spin.is_set(): - # set the hidden spinner flag - self._hide_spin.set() - - # clear the current line - sys.stdout.write("\r") - self._clear_line() - - # flush the stdout buffer so the current line can be rewritten to - sys.stdout.flush() + with self._stdout_lock: + # set the hidden spinner flag + self._hide_spin.set() + + # clear the current line + sys.stdout.write("\r") + self._clear_line() + + # flush the stdout buffer so the current line + # can be rewritten to + sys.stdout.flush() def show(self): """Show the hidden spinner.""" thr_is_alive = self._spin_thread and self._spin_thread.is_alive() if thr_is_alive and self._hide_spin.is_set(): - # clear the hidden spinner flag - self._hide_spin.clear() - - # clear the current line so the spinner is not appended to it - sys.stdout.write("\r") - self._clear_line() + with self._stdout_lock: + # clear the hidden spinner flag + self._hide_spin.clear() + + # clear the current line so the spinner is not appended to it + sys.stdout.write("\r") + self._clear_line() def write(self, text): """Write text in the terminal without breaking the spinner.""" # similar to tqdm.write() # https://pypi.python.org/pypi/tqdm#writing-messages - sys.stdout.write("\r") - self._clear_line() + with self._stdout_lock: + sys.stdout.write("\r") + self._clear_line() - _text = to_unicode(text) - if PY2: - _text = _text.encode(ENCODING) + _text = to_unicode(text) + if PY2: + _text = _text.encode(ENCODING) - # Ensure output is bytes for Py2 and Unicode for Py3 - assert isinstance(_text, builtin_str) + # Ensure output is bytes for Py2 and Unicode for Py3 + assert isinstance(_text, builtin_str) - sys.stdout.write("{0}\n".format(_text)) + sys.stdout.write("{0}\n".format(_text)) def ok(self, text="OK"): """Set Ok (success) finalizer to a spinner.""" @@ -306,7 +311,8 @@ # Should be stopped here, otherwise prints after # self._freeze call will mess up the spinner self.stop() - sys.stdout.write(self._last_frame) + with self._stdout_lock: + sys.stdout.write(self._last_frame) def _spin(self): while not self._stop_spin.is_set(): @@ -321,9 +327,10 @@ out = self._compose_out(spin_phase) # Write - sys.stdout.write(out) - self._clear_line() - sys.stdout.flush() + with self._stdout_lock: + sys.stdout.write(out) + self._clear_line() + sys.stdout.flush() # Wait time.sleep(self._interval) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yaspin-0.14.2/yaspin.egg-info/PKG-INFO new/yaspin-0.14.3/yaspin.egg-info/PKG-INFO --- old/yaspin-0.14.2/yaspin.egg-info/PKG-INFO 2019-04-27 23:11:40.000000000 +0200 +++ new/yaspin-0.14.3/yaspin.egg-info/PKG-INFO 2019-05-12 15:31:30.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: yaspin -Version: 0.14.2 +Version: 0.14.3 Summary: Yet Another Terminal Spinner Home-page: https://github.com/pavdmyt/yaspin Author: Pavlo Dmytrenko
participants (1)
-
root