Bug: When used as a context manager, spinner starts itself
See original GitHub issueDescription
When used as a context manager, a Halo spinner starts itself before .start() is called.
Expected behaviour
The spinner should not start until .start() is called explicitly
Steps to recreate
with Halo(color="grey",spinner="clock",placement="left", animation="marquee") as spinner:
try:
with db.authenticate_user as db_connection: #prompts for username/password, hidden if spinner is running
spinner.start("doing something")
#do something
except DBException:
spinner.fail("caught exception")
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
The sqlite3 context manager does not work with ... - GitHub
I belive that using the connection as a context manager is an inadequate API for controlling transactions because it's very likely to result...
Read more >contextlib — Utilities for with-statement contexts ... - Python Docs
contextmanager () uses ContextDecorator so the context managers it creates can be used as decorators as well as in with statements. When used...
Read more >Writing a context manager in Python that itself uses a with ...
My use case is a login context manager for testing a view (in a webapp). Logging in requires a couple of calls to...
Read more >The Curious Case of Python's Context Manager
Python's context managers are great for resource management and stopping the propagation of leaked abstractions. You've probably used it ...
Read more >Context | Android Developers
Use with getSystemService(java.lang.String) to retrieve a AudioManager for handling management of volume, ringer modes and audio routing.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
No, the existing behavior seems like the right behavior to me, so I was surprised that you considered it to be a bug. I think most users will expect the context manager to start a spinner immediately; requiring users to explicitly start the spinner will just add verbosity, making the context manager less elegant.
The context manager is just a shortcut for a common case, so perhaps it is not a good tool for @norweeg’s application, and he should avoid it. An option to disable auto-starting could also be useful, though all options add maintenance cost.
Didn’t realize I left this open.