INNER CODE UNIT · Python

is_running_in_mp_timeout

buckaroo-data/buckaroo · buckaroo/__init__.py:79

def is_running_in_mp_timeout() -> bool:
    """
    Check if the current code is running inside an mp_timeout decorator.
    
    Returns True if the current call stack includes either _execute_and_report
    or _execute_and_report_fork, which are the functions that execute code
    within the multiprocessing worker processes created by mp_timeout.
    
    Returns:
        bool: True if running inside mp_timeout decorator, False otherwise
    """
    try:
        stack = inspect.stack()
        for frame_info in stack:
            func_name = frame_info.function
            if func_name in ('_execute_and_report', '_execute_and_report_fork'):
                return True
        return False

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…