➜

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
标题: Python should expose a pthread_cond_timedwait API for threading
类型: enhancement Stage:
Components: Interpreter Core Versions:
process
状态: closed Resolution: out of date
Dependencies: 后续: Add a timeout functionality to common locking operations
View: 7316
分配给: 抄送列表: BreamoreBoy, Rhamphoryncus, gregory.p.smith, pitrou
优先级: normal 关键字:

Created on 2008-06-20 23:23 by gregory.p.smith, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg68484 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) 日期: 2008-06-20 23:23
Currently the threading module has loops in it such as
threading.Condition.wait's loop that attempts to acquire a lock in
non-blocking mode and if it fails, sleeps for a while and trys again. 
(with exponential backoff of sleep time from 500us to 50ms in the
current implementation).

This is inefficient.

Perhaps pthread_cond_timedwait does the same thing internally in some
implementations but even if so, it will do it a lot more efficiently
than doing it in python.

We should expose a PyThread_acquire_lock API that accepts a timeout and
uses pthread_cond_timedwait (or the equivalent on other OSes) when
available.

caveats?  This may alter behavior with regards to KeyboardInterrupt
exceptions coming in being processed or not depending on the particular
OS timedwait implementation.
msg109299 - (view) Author: Mark Lawrence (BreamoreBoy) * 日期: 2010-07-05 05:31
Is anybody with knowledge of the threading module likely to pick this one up?
msg109578 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) 日期: 2010-07-08 19:35
I hadn't seen this issue existed. This has been done in r80071 (see issue #7316).
历史
日期 用户 动作 参数
2022-04-11 14:56:35admin修改github: 47405
2010-07-08 19:35:07pitrou修改状态: open -> closed

抄送: + pitrou
消息: + msg109578

后续: Add a timeout functionality to common locking operations
resolution: out of date
2010-07-05 05:31:05BreamoreBoy修改抄送: + BreamoreBoy
消息: + msg109299
2008-06-21 17:16:16Rhamphoryncus修改抄送: + Rhamphoryncus
2008-06-20 23:23:26gregory.p.smith创建