Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed issue #433 - CLI eats cursor #598

Merged
merged 1 commit into from Nov 4, 2023
Merged

Commits on Oct 4, 2023

  1. Fixed issue simonw#433 - CLI eats cursor

    The issue is that underlying iterator is not fully consumed within the body of
    the `with file_progress()` block. Instead, that block creates generator
    expressions like `docs = (dict(zip(headers, row)) for row in reader)`
    
    These iterables are consumed later, outside the `with file_progress()` block,
    which consumes the underlying iterator, and in turn updates the progress bar.
    
    This means that the `ProgressBar.__exit__` method gets called before the last
    time the `ProgressBar.update` method gets called. The result is that the code to
    make the cursor invisible (inside the `update()` method) is called after the
    cleanup code to make it visible (in the `__exit__` method).
    
    The fix is to move consumption of the `docs` iterators within the progress bar block.
    
    (An additional fix, to make ProgressBar more robust against this kind of misuse, would
    to make it refusing to update after its `__exit__` method had been called, just
    like files cannot be `read()` after they are closed. That requires a in the
    click library).
    spookylukey committed Oct 4, 2023
    Copy the full SHA
    76113d1 View commit details
    Browse the repository at this point in the history