[issue39557] ThreadPoolExecutor is busy-waiting when idle.

Maor Kleinberger report at bugs.python.org
Thu Feb 20 16:00:21 EST 2020


Maor Kleinberger <kmaork at gmail.com> added the comment:

> If I understand the following code correctly, there seems to be a busy loop waiting for the SimpleQueue.put to signal that an item was entered to queue.

This is not a busywait. Actually, the loop you specified will never repeat more than twice. At the first iteration, the queue's lock is acquired. At the second iteration, the loop waits for the lock to be released (by trying to acquire the lock again, which is not busywait). The lock is only released when something is put into the queue, so at that point the loop exits and the function returns.

Avraham, could you provide a minimal python script that will reproduce the CPU usage spike?

----------
nosy: +kmaork

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39557>
_______________________________________


More information about the Python-bugs-list mailing list