[Python] How can I debug a single thread, while multithreading in VsCode?

Discussão em 'Python' iniciado por Stack, Novembro 29, 2024.

  1. Stack

    Stack Membro Participativo

    While working on VsCode on my Mac, I am multithreading code. I don't get the expected result for one thread and want to debug this thread. However, I have not been able to debug a single thread.

    This is the initial multithreading code:

    for i, matched_component_name in enumerate(matched_component_names):
    thread = threading.Thread(target=create_component_multithreaded, args=(
    matched_component_name, api, api_calls, app_data, pipeline_parameters, model_parameters, extracted_nodes_and_properties, catalog_components, logger, output, i
    ))
    threads.append(thread)
    thread.start()

    for thread in threads:
    thread.join()

    return list(filter(bool, output))


    I have tried adding if matched_component == <positive_condition> and then setting a breakpoint in the following line. However, when the breakpoint is set, it pauses all threads.

    Similarly, I have edited my breakpoint, to meet the same condition. But also here the other threads are being paused when this breakpoint is hit, when the condition is met.

    Lastly, I tried resuming the other threads (both by clicking the resume button in the specific threads in the Call Stack section and by clicking F5 while having specific threads selected. In both cases, all threads are continued and I cannot debug one specific thread.

    How can I debug a single thread?

    Continue reading...

Compartilhe esta Página