New submission from Antoine Pitrou <pit...@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 <rep...@bugs.python.org> <http://bugs.python.org/issue7316> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com