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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

there is logical bug in code #186

Open
kim2002zz opened this issue Nov 4, 2024 · 1 comment
Open

there is logical bug in code #186

kim2002zz opened this issue Nov 4, 2024 · 1 comment

Comments

@kim2002zz
Copy link

kim2002zz commented Nov 4, 2024

Description

While using the Halo package to implement a spinner, a MemoryError occurs when processing long text. The issue stems from a logical error in the _get_text method of the Halo class, where a condition always evaluates to true, causing the 'marquee' animation logic to execute regardless of the animation parameter's value. This results in excessive and unnecessary frame generation, leading to a rapid increase in memory usage.

System settings

  • Operating System: Windows 10
  • Terminal in use:
  • Python version: 3.12.2
  • Halo version: 0.0.31
  • pip freeze output:

Error

Traceback (most recent call last):
File "your_script.py", line 100, in
spinner = Halo(spinner='circleQuarters', placement='right', color='magenta')
File "halo\halo.py", line 112, in init
MemoryError

Expected behaviour

When using the Halo class, even when processing long text, memory usage should remain within normal limits, and a MemoryError should not occur.

Steps to recreate

from halo import Halo

spinner = Halo(spinner='circleQuarters', placement='right', color='magenta')
spinner.start("This is a very long text that will be displayed alongside the spinner. This text is long enough to exceed the terminal's width.")

People to notify

It usually occurs on computers with low specifications.

@kim2002zz
Copy link
Author

The root cause is in the _get_text method of the halo.py file, specifically in the following conditional statement:

elif "marquee":
This condition always evaluates to True, causing the 'marquee' animation logic to execute even when animation is None or another value. It should be corrected as follows:

elif animation == "marquee":
By making this change, the 'marquee' animation logic will only execute when animation is explicitly set to 'marquee', ensuring that memory usage remains normal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant