8000 feature request: suspended mode · Issue #5 · victorbenichoux/ticktock · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feature request: suspended mode #5

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 priva 8000 cy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
gilbh opened this issue Nov 11, 2021 · 8 comments
Closed

feature request: suspended mode #5

gilbh opened this issue Nov 11, 2021 · 8 comments

Comments

@gilbh
Copy link
gilbh commented Nov 11, 2021

Hi,

I could not find in documentation: is there a way of temporarily shutting off all ticktock calls? This is helpful for switching between debug and production modes.

Thanks!

@victorbenichoux
Copy link
Owner

Hi @gilbh !

Currently, there is no such mode, but it seems like it would be relatively easy to implement 😄 . I will try to think of a good way to do it.

@gilbh
Copy link
Author
gilbh commented Nov 12, 2021

Great! Keep me posted when it is added.

@victorbenichoux
Copy link
Owner
victorbenichoux commented Nov 12, 2021

What would you think of something like this:

import ticktock

@ticktock.ticktock()
def f():
    pass

# these are counted
f()
f()
 
ticktock.disable()
# this call is discarded
f()
 
ticktock.enable()
# these are counted again
f()
f()

@gilbh
Copy link
Author
gilbh commented Nov 12, 2021

Fantastic.

Few small ideas:

  1. instead of two separate call, make one function toggle(). It could take an optional action parameter, with: auto, on, off, the default is auto which toggles the current state.
  2. From the user end, my own tendency (and it is just a tendency) is to limit namespace of imports:
from ticktock import ticktock as tc, toggle as tc_tgl

I mention that b/c @ticktock.ticktock() is very long, compared with @tc_tgl

These are just passing ideas. Keep on rocking.

@victorbenichoux
Copy link
Owner

Thanks (again) for the constructive feedback!

  1. I am sort of worried about the toggle idea here, I am worried that it would be hard to keep track of the current enabled/disabled state of the clock (and worse, their clockcollection). In addition, it could create headaches toggling the state of a collection that has both enabled and disabled clocks (see the documentation in my PR)

  2. I agree with your note on the namespace. I was being overly verbose in the example 😄 . In general, I think I would advise for importing tick and ticktock directly with from ticktock import tick, ticktock.

@gilbh
Copy link
Author
gilbh commented Nov 13, 2021

Cool. As for item #2: would the user need to import disable() and enable() as well? Or any way to reduce that? (Sorry for being a stickler, all's is well with things as they are!).

@victorbenichoux
Copy link
Owner

At the moment, yes. I'll see about adding the toggle in another PR. Hopefully I'll be able to get it done tomorrow and push a new release to PyPi. I will leave this issue open as a reminder 😄 .

@victorbenichoux
Copy link
Owner

I have made a release with enable/disable, I will open a new issue for the implementation of the toggle!

Thanks for contributing!

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

2 participants
0