Skip to content Skip to sidebar Skip to footer

Thread._wait_for_tstate_lock() Never Returns

My program appears to run in a deadlock sometimes when I hit Ctrl+C. I'm trying to catch the keyboard interrupt and gracefully stop all running threads, but I'm not quite there yet

Solution 1:

I'm not 100% certain it's the reason you're seeing this as you are using Windows, but I encountered this on Linux with Python 3.6 in a similar scenario.

I was using .shutdown() on a concurrent.futures.ThreadPoolExecutor and the program would seem to hang up. Sometimes it would finally exit after 30-60 seconds.

Ctrl-C always resulted in a traceback showing it was sitting in _wait_for_tstate_lock()

Note: in Python 3 a second Ctrl-C actually exits

My problem occurred when the function submitted was using time.sleep() in a loop.

Looking at the HtmlFileTracer implementation in current nodepy code on github I see a similar scenario to what I was doing, (continuously loop and sleep for an interval unless some sort of flag was set)


Post a Comment for "Thread._wait_for_tstate_lock() Never Returns"