logging from time critical tasks -- QueueListener().stop() takes the whole CPU

Cameron Simpson cs at cskk.id.au
Mon Jul 16 04:00:31 EDT 2018

On 16Jul2018 08:33, Thomas Jollans <tjol at tjol.eu> wrote:
>On 16/07/18 08:24, Gerlando Falauto wrote:
>> On Monday, July 16, 2018 at 8:13:46 AM UTC+2, Thomas Jollans wrote:
>>> On 16/07/18 07:39, Gerlando Falauto wrote:
>>>> On Monday, July 16, 2018 at 6:56:19 AM UTC+2, dieter wrote:
>>>>>> ...
>>>>>> Why is the main thread taking up so much CPU?
>>>>>> I believe at this point listener.stop() should only be waiting for the helper thread to terminate, which I reckon would be implemented by waiting on a semaphore or something (i.e. iowait i.e. 0% CPU).

Presuming you're using Linux on the Pi, the strace command will show you 
exactly what system calls the processis making. A real spin lock situation will 
be very apparent. 100% CPU with no system calls means a busy wait (polling).

Strace is an outstandingly useful and often overlooked tool for debugging 
otherwise opaque behaviour.

Cameron Simpson <cs at cskk.id.au>

More information about the Python-list mailing list