New submission from Gregory P. Smith <[EMAIL PROTECTED]>:

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.

----------
components: Interpreter Core
messages: 68484
nosy: gregory.p.smith
priority: normal
severity: normal
status: open
title: Python should expose a pthread_cond_timedwait API for threading
type: feature request

_______________________________________
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue3155>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to