-
-
Notifications
You must be signed in to change notification settings - Fork 30.8k
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 privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bpo-29569: threading.Timer class: Continue periodical execution till action return True #121
Conversation
…action returns True.
I've fixed test for continuous execution of Timer class. Now check passed. |
I am wondering how it will influence existing code. Most of the functions currently used in Timer callback probably not returning True value. It means that they will be executed infinitely. Maybe it's better to add some new argument like |
No, exactly conversely - if function returns None or not True it will run only once. |
@slytomcat right, sorry, my bad |
codecov/patch — 81.25% of diff hit (target 100%) - anybody know how to fix it? |
Lib/threading.py
Outdated
if not self.finished.is_set(): | ||
self.function(*self.args, **self.kwargs) | ||
"""Continue execution after wait until function returns True""" | ||
while(not self.finished.wait(self.interval)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try to add test case when this is true. It might help you get 100% coverage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. But: codecov/patch — 86.95% of diff hit (target 100%) - some red lines in Lib/test/test_threading.py.
I have no idea how to cover tests by tests =/
I have to reorganize my cloned repo so the CR have to be reissued. |
Reopened CR: #191 |
…ile clearing a thread state If Python clears a thread state and a destructor or a weakref-callback runs Python code, Python used to create a new initial stub without clearing it later. This change reorders PyThreadState_Clear() to clear the PyStacklessState sub-structure last. A new test case for this problem uses thread local storage to execute a __del__-method. https://bitbucket.org/stackless-dev/stackless/issues/121 (grafted from ede2ad2b32b917d364f523318a82c75d0df2a0e6)
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.
http://bugs.python.org/issue29569
As most current CB functions that are used in Timer returns nothing (None) they will run only once as earlier. Only functions that returns True will continue their periodical execution.
There are two ways to stop such continues execution:
It is my first contribution and I kindly ask to help me with required future actions.
Thanks