You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
with Timer(1, print, ("Trust me, I'm on it...",)):
time.sleep(2)
Users of the threading module will probably already be familiar with the context management features of a lock. Chaining the two together is a great way to provide feedback IF it’s needed, gotta reduce that alarm fatigue!
hold_message = Timer(10, print, ("Please hold, your call is important to us...",))
with some_lock, hold_message:
...
Looking to exact those changes on the core library
Has this already been discussed elsewhere?
I have already discussed this feature proposal on Discourse
Feature or enhancement
Proposal:
Proposing to add context management to threading.Timer.
I had an issue where I didn’t want to ask the user to be patient unless they had already been waiting a while. Timer works nicely for this:
Enclosing calls of start and cancel call out for context management for the obvious reasons. Sub-classing and adding it was trivial:
The first example now looks like this:
Users of the threading module will probably already be familiar with the context management features of a lock. Chaining the two together is a great way to provide feedback IF it’s needed, gotta reduce that alarm fatigue!
Looking to exact those changes on the core library
Has this already been discussed elsewhere?
I have already discussed this feature proposal on Discourse
Links to previous discussion of this feature:
https://discuss.python.org/t/adding-context-manger-to-threading-timer/64083
Linked PRs
The text was updated successfully, but these errors were encountered: