Module openrelik_worker_common.debug_utils

Functions

def start_debugger(port: int = 5678)
Expand source code
def start_debugger(port: int = 5678):
    """Setup the Python Debugger.

    This function initializes the debugpy library, allowing you to attach a debugger to your Python process.
    It checks for the environment variable `OPENRELIK_PYDEBUG` to determine if debugging should be enabled.
    If enabled, it also checks for the `OPENRELIK_PYDEBUG_PORT` environment variable to specify a custom port.

    Args:
        port: The port to listen on. Defaults to 5678.
    """
    import debugpy

    if os.getenv("OPENRELIK_PYDEBUG_PORT"):
        port = os.getenv("OPENRELIK_PYDEBUG_PORT")

    print(f"Starting debugpy on {port}\n")
    debugpy.listen(("0.0.0.0", int(port)))

Setup the Python Debugger.

This function initializes the debugpy library, allowing you to attach a debugger to your Python process. It checks for the environment variable OPENRELIK_PYDEBUG to determine if debugging should be enabled. If enabled, it also checks for the OPENRELIK_PYDEBUG_PORT environment variable to specify a custom port.

Args

port
The port to listen on. Defaults to 5678.