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.
Created on 2007年03月05日 13:33 by davidfraser, last changed 2022年04月11日 14:56 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| event-wait-retval.diff | tlesher, 2008年05月06日 16:28 | proposed patch for threading.py and documentation | ||
| Messages (9) | |||
|---|---|---|---|
| msg55044 - (view) | Author: David Fraser (davidfraser) | Date: 2007年03月05日 13:33 | |
Currently the wait method on threading.Event always returns None, even if a timeout is given and the event is not set. This means that there is no way to determine whether the wait method returned because the event was set, or because the timeout period expired, without querying the event status again: x.wait(3) if x.isSet(): # do stuff Note that in the above case, the event could be cleared between the return from x.wait and the execution of x.isSet (in another thread), and so this would operate as though x.wait had just timed out It would be great to be able to do: if x.wait(3): # do stuff This should also not affect any existing code as it shouldn't be relying on the return value from x.wait anyway |
|||
| msg66317 - (view) | Author: Tim Lesher (tlesher) * | Date: 2008年05月06日 16:28 | |
This one-line change to threading.py makes Event.wait() return isSet(). Also includes the corresponding update to documentation in threading.rst. |
|||
| msg66324 - (view) | Author: Georg Brandl (georg.brandl) * (Python committer) | Date: 2008年05月06日 17:22 | |
Tim, you said this was a bad idea for conditions in #1175933 - is the same true for Events? |
|||
| msg71566 - (view) | Author: Adam Milner (carmiac) | Date: 2008年08月20日 18:44 | |
I would like to add my support for this change. As David described, it is often useful to know why the x.wait() has returned, not just that it has. |
|||
| msg72697 - (view) | Author: Antoine Pitrou (pitrou) * (Python committer) | Date: 2008年09月06日 21:16 | |
I agree this would be a worthwhile addition too. Unfortunately given the current schedule this will probably have to wait for 2.7/3.1. |
|||
| msg83556 - (view) | Author: Antoine Pitrou (pitrou) * (Python committer) | Date: 2009年03月14日 01:09 | |
A test should be added to the patch, and then I think it could go in. |
|||
| msg84546 - (view) | Author: Tim Lesher (tlesher) * | Date: 2009年03月30日 14:07 | |
Thanks, Antoine. I will re-check the patch against trunk and add tests this week. |
|||
| msg84569 - (view) | Author: Guido van Rossum (gvanrossum) * (Python committer) | Date: 2009年03月30日 15:53 | |
Looking at this, I think this change is fine. The _Event class itself holds the condition that it's checking for, and the is_set() method doesn't acquire the lock, so there's no reason to prefer e.wait() if e.is_set(): GOT_IT() over if e.wait(): GOT_IT() IOW Tim's reasoning in #1175933 for rejecting a similar change to _Condition.wait() doesn't apply here. I think we can go ahead without waiting for Tim to confirm this. |
|||
| msg84895 - (view) | Author: Georg Brandl (georg.brandl) * (Python committer) | Date: 2009年03月31日 20:41 | |
Added a pony test and committed in r70883. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:56:22 | admin | set | github: 44660 |
| 2009年03月31日 20:41:16 | georg.brandl | set | status: open -> closed assignee: tim.peters -> georg.brandl resolution: accepted messages: + msg84895 |
| 2009年03月30日 15:53:25 | gvanrossum | set | nosy:
+ gvanrossum messages: + msg84569 |
| 2009年03月30日 14:07:37 | tlesher | set | messages: + msg84546 |
| 2009年03月14日 01:10:00 | pitrou | set | messages: + msg83556 |
| 2008年09月06日 21:16:59 | pitrou | set | nosy:
+ pitrou messages: + msg72697 versions: + Python 3.1, Python 2.7, - Python 2.6 |
| 2008年09月06日 21:11:46 | akuchling | set | components: - Documentation |
| 2008年08月20日 18:44:40 | carmiac | set | nosy:
+ carmiac messages: + msg71566 |
| 2008年05月06日 17:22:05 | georg.brandl | set | assignee: georg.brandl -> tim.peters messages: + msg66324 nosy: + tim.peters |
| 2008年05月06日 16:43:17 | tlesher | set | assignee: georg.brandl components: + Documentation, Library (Lib), - Interpreter Core nosy: + georg.brandl |
| 2008年05月06日 16:28:03 | tlesher | set | files:
+ event-wait-retval.diff keywords: + patch messages: + msg66317 nosy: + tlesher |
| 2007年03月05日 13:33:33 | davidfraser | create | |