Title: threading.Timer class: Continue periodical execution till action returns True
Type: enhancement Stage:
Components: Library (Lib) Versions: Python 3.7
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: rhettinger, slytomcat
Priority: normal Keywords:

Created on 2017-02-15 14:54 by slytomcat, last changed 2017-02-23 03:14 by rhettinger.

Pull Requests
URL Status Linked Edit
PR 191 open slytomcat, 2017-02-20 09:44
Messages (2)
msg287858 - (view) Author: (slytomcat) * Date: 2017-02-15 14:54
I think that functionality of threading.Timer class can be easily extended to generate the sequence of runs with specified period. The idea comes from the GLib.timeout_add function. 

Run method of threading.Timer should look like:

    def run(self):
        """Continue execution after wait till function returns True"""
        while(not self.finished.wait(self.interval)):
            if not self.function(*self.args, **self.kwargs):
msg288398 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2017-02-23 03:14
Ideally, proposed API expansions should be based on a demonstrated user need. This API is over decade old and I don't recall a single user request for this functionality.  A quick scan of StackOverflow didn't turn-up any questions or answers on the subject.

I don't see anything intrinsically wrong with the idea, but in the absence of demonstrated need, it is likely to become unused cruft with it attendant burden on maintenance and cognitive load.
Date User Action Args
2017-02-23 03:14:54rhettingersetnosy: + rhettinger
messages: + msg288398
2017-02-20 11:32:53slytomcatsetpull_requests: - pull_request81
2017-02-20 09:44:36slytomcatsetpull_requests: + pull_request157
2017-02-15 15:01:15slytomcatsetpull_requests: + pull_request81
2017-02-15 14:54:10slytomcatcreate