Using time.sleep() in 2 threads causes lockup when hyper-threading is enabled

OlafMeding at gmail.com OlafMeding at gmail.com
Wed May 3 21:52:47 EDT 2006


Tim

> I didn't run it for hours ;-)

Please try.

The sleep statement does not return!  And this should not happen.  The
code above does nothing special or unusual.  The problem only occurs if
2 threads use the sleep statement and hyper-threading is enabled.

We discovered this bug perhaps a year ago.  The only solution was to
tell our customers to disable hyper-threading (you can imagine they did
not like our "solution" very much).  It then took many days of hard
work to isolate the problem down to the code I posted above.

> Where "hang" means they stop printing.

Our Python code just stops running (locking up the entire application).
 We use Qt for our GUI.  We have over a hundred .py files.  We use a
total of 4 threads (they get created once and stay running).  One
thread uses sockets.

Once the application locks up (getting stuck in a sleep statement) all
comes back to live if I pull the network cable out.  So perhaps the
socket thread returns from the sleep statement and other threads return
to live because they were waiting for the socket thread.

Our software runs on both Windows and Linux.  We are not sure if the
problem also happens on Linux.

In any case, if someone else can confirm the bug then this is a serious
problem meriting further investigation.

We have searched the Internet far and wide and were not able to find
any information that indicates that someone else has reported a similar
problem (neither Python nor Windows Sleep related).

Thank you for your help.

Olaf




More information about the Python-list mailing list