This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: sched.py: run() is caught in delayfunc even if all events are cancelled.
Type: enhancement Stage: test needed
Components: Library (Lib) Versions: Python 3.9
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: ernestum, rhettinger, terry.reedy, tim.peters
Priority: normal Keywords:

Created on 2019-06-06 12:06 by ernestum, last changed 2022-04-11 14:59 by admin.

Pull Requests
URL Status Linked Edit
PR 13862 open ernestum, 2019-06-06 12:06
Messages (3)
msg344804 - (view) Author: Maximilian Ernestus (ernestum) * Date: 2019-06-06 12:06
When I remove all events from a scheduler while its run() is being executed (with blocking=True in another thread), run() continues to block for some time because it is caught in its delayfunc which is time.sleep by default.

This issue can easily be solved by using the wait() function of a threading.Event as the delayfunc and setting the event whenever the queue becomes empty. The referenced pull request adds this functionality by default.

I also added a cancel_all() method which should be far more efficient than iterating all events and deleting them individually.
msg345021 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2019-06-08 03:32
3.6 only gets security fixes.  3.7, 3.8 only get bugfixes.  Something new should be a separate PR.
msg345023 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2019-06-08 05:49
Marking this as 3.9 because it is an API change.  Also, you can already control the delayfunc through the current API, so I don't see the necessity of a changing the default which seems to work fine for most users.

Tim, what do you think?
History
Date User Action Args
2022-04-11 14:59:16adminsetgithub: 81355
2019-06-08 05:49:36rhettingersetnosy: + rhettinger, tim.peters

messages: + msg345023
versions: - Python 3.7, Python 3.8
2019-06-08 03:32:20terry.reedysetversions: - Python 3.6
nosy: + terry.reedy

messages: + msg345021

stage: test needed
2019-06-06 12:06:26ernestumcreate