Does the Python debugger support breakpoints set in a different thread?

It appears that the answer is no. But I wanted to make sure that it is the case.

To reproduce the issue, run the Debbuger Integration - Python demo and put the following code:

import time
import threading
from queue import Empty, Queue
from threading import *

def producer(queue):
    for i in range(1, 6):
        print(f'Inserting item {i} into the queue')
        time.sleep(1)
        queue.put(i)

def consumer(queue):
    while True:
        try:
            item = queue.get()
        except Empty:
            continue
        else:
            print(f'Processing item {item}')
            time.sleep(2)
            queue.task_done()

def main():
    queue = Queue()

    consumer_thread = threading.Thread(target=consumer, args=(queue,))
    consumer_thread.start()
    
    producer(queue)
    queue.join()

main()
print("done")

Then, set a breakpoint on line 19 where the “print()” statement exists in the “else:” block and click the Start button.

The script starts executing and the Output pane shows the expected results. But the breakpoint is never hit.

Is there any way to allow breakpoints on other threads? If the Alternet source code changes are needed to do so, please let me know the details of the changes.

Thanks!

Thank you for reporting this bug. The fix is already done, and is being tested. I will write you an email shortly with the details on how to apply the changes to the source code.

Thank you for the fix.