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
Title: Threading.Condition.wait is non-iteruptable
Type: behavior Stage:
Components: Library (Lib) Versions: Python 2.5
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: gvanrossum, ronaldoussoren
Priority: low Keywords:

Created on 2007-12-20 09:23 by ronaldoussoren, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg58865 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2007-12-20 09:23
The scriptlet below hangs (as expected) but is also not interuptable by 
Ctrl+C, at least on Linux and Mac OS X:

from Queue import Queue, Empty, Full

q = Queue()
q.get(True)

This is due to Threading.Condition.wait not being interuptable.
msg58891 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2007-12-20 15:25
This can't be fixed directly -- the pthreads mutex is not an
interruptable system call.

However there's a simple (though expensive) work-around: use a very long
timeout. The timeout version of waiting for a lock is a busy-wait with a
short sleep (much less than a second I recall), and it is interruptable
while sleeping.

Only do this when it's really important to be interruptable -- the
busy-waiting makes your code use up battery power (see #1583).
History
Date User Action Args
2022-04-11 14:56:29adminsetgithub: 46011
2007-12-20 15:25:32gvanrossumsetstatus: open -> closed
resolution: wont fix
messages: + msg58891
nosy: + gvanrossum
2007-12-20 09:23:04ronaldoussorencreate