[issue8055] Sleeping after acquiring RLock causes acquire to block in other thread

Knut Eldhuset report at bugs.python.org
Thu Mar 4 13:19:16 CET 2010


New submission from Knut Eldhuset <knut.eldhuset at gmail.com>:

In essence I have the following loop running in thread A:

while True:
    with self.lock:
        time.sleep(0.1)

I then try to acquire the lock in thread B. This blocks forever on Linux, but runs fine on Windows XP.

The following modification makes the code behave as expected on Linux:

while True:
    time.sleep(0.001)
    with self.lock:
        time.sleep(0.1)

See the attached file for the full example. Python versions are:

Python 2.6.4 (r264:75706, Dec  7 2009, 18:45:15)
[GCC 4.4.1] on linux2

and

Python 2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC v.1500 32 bit (Intel)] on win32

----------
components: Library (Lib)
files: threadtest.py
messages: 100383
nosy: knutel
severity: normal
status: open
title: Sleeping after acquiring RLock causes acquire to block in other thread
versions: Python 2.6
Added file: http://bugs.python.org/file16430/threadtest.py

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue8055>
_______________________________________


More information about the Python-bugs-list mailing list