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
improvements to sched.py #52930
Comments
This patch is against Python trunk, but it could be easily targeted for Python 3.2 . It is meant to extract the scheduler updates from bpo-1641 without mucking with asyncore. It's reach is reduced and simplified, which should make maintenance a bit easier. |
This must be retargeted to 3.2. Also, the patch lacks some tests. |
By the way, the patch lacks docs for new public APIs. |
What are the enhancements introduced by this patch? I've noticed there are no existing tests for the sched module. Obviously it is also crucial that this patch is fully backward compatible with the current implementation. |
Created bpo-8687 to address the test suite problem. |
sched.py tests have been checked in. |
Josiah are you still interested in this? |
Looking back at this patch, I think we can extract the thread-synchronization parts and the peek() method, as they're both valuable additions, especially the first one. The very sched doc says:
|
Updated patch adding a synchronized argument to scheduler class and updating doc is in attachment. |
I'm not convinced by the decorator approach. Why not simply add "with self.lock" at the beginning of each protected method? It would actually save a function call indirection. |
Are you suggesting to enable thread-synchronization by default and get rid of explicit "synchronized" argument? |
That would be even better indeed, if you find out that there's no |
This is what I get by using bench.py script attached to bpo-13451: CURRENT VERSION (NO LOCK) test_cancel : time=0.67457 : calls=1 : stdev=0.00000 LOCK WITH DECORATOR (no synchronization) test_cancel : time=0.70455 : calls=1 : stdev=0.00000 LOCK WITHOUT DECORATOR (always synchronized) test_cancel : time=0.69625 : calls=1 : stdev=0.00000 Versions #2 and #3 have the same cost, so it's better to get rid of the explicit argument and always use the lock (version #3). |
It looks quite negligible to me. Nobody should be affected in practice. |
New patch in attachment. I'll commit it later today. |
New changeset f5aed0dba844 by Giampaolo Rodola' in branch 'default': |
This broken the "Fedora without thread buildbot", since sched now requires the threading module: |
New changeset 50267d2bb320 by Giampaolo Rodola' in branch 'default': |
This should now be fixed. Thanks for signaling. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: