question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug: When used as a context manager, spinner starts itself

See original GitHub issue

Description

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:closed
  • Created 5 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
tdsmithcommented, Mar 9, 2019

Do you also have a usecase for fixing this?

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.

0reactions
norweegcommented, Mar 7, 2020

Didn’t realize I left this open.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found