[New-bugs-announce] [issue7316] Add a timeout functionality to common locking operations

Antoine Pitrou report at bugs.python.org
Fri Nov 13 18:31:48 CET 2009

New submission from Antoine Pitrou <pitrou at free.fr>:

Here is a patch which adds a timeout feature to the locking operations
provided by Python. This feature is added at two levels:
- the C API level, with a new function PyThread_acquire_lock_timed()
- the Python level, with an optional `timeout` argument to the acquire()
method of Lock and RLock objects (it also helps simplify the wait()
function of Condition objects)

The timeout duration is expressed in microseconds at the C API level,
and in seconds at the Python API level. There is also a new Python-level
constant, `_thread.TIMEOUT_MAX`, indicating the max allowable timeout
value (values above this raise an OverflowError).

At the C level, the max timeout is PY_TIMEOUT_MAX (in microseconds). The
caller should check the value him/herself.

The patch contains both a POSIX implementation and a Windows
implementation. It still lacks docs.

components: Interpreter Core, Library (Lib)
files: timedlock.patch
keywords: patch
messages: 95192
nosy: gps, pitrou
priority: normal
severity: normal
status: open
title: Add a timeout functionality to common locking operations
type: feature request
versions: Python 3.2
Added file: http://bugs.python.org/file15321/timedlock.patch

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list