Skip to content

Bug with settign breakpoints in discovered pyblish plugins #405

Description

@quitinit

The Problem

I encountered the issue that setting breakpoints in discovered plugins does not trigger that breakpoint. If the plugin has been registered manually, it will, but using pyblish.api.discover() it will go past the breakpoint in the plugin

How to reproduce the problem

I have created a seperate repository with a small example. Essentially, you set a breakpoint inside a plugin that has been added to the plugin_path before. When running it in vscode with the provided .vscode settings, it should trigger a breakpoint. However it does not.

The reason for the bug

The import mechanism is not quite correct in the discover method.
In plugin.py we use six.exec_ on a raw bytestream. This does import the plugin, however, for each object inside the module, python typically generates a code method. When using the normal import statement, python compiles the code before running exec on it. Crucially, with that compile step it associates the code method with a file. When the code then triggers a breakpoint, the debugger knows in which file it does so and can halt the execution. With the current approach there is no file associated. I attached two screenshots

image
how it is right. now
image
how it should be

My research on this topic is backed by this article

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions