0.1.33
Loading...
Searching...
No Matches
pyhelios.wrappers.UParameterOptimizationWrapper._CallbackState Class Reference

Carries a Python exception raised inside a callback back to the caller. More...

Detailed Description

Carries a Python exception raised inside a callback back to the caller.

A Python exception cannot propagate through the intervening C++ frames. Worse, ctypes does not even let it escape the callback: it prints the traceback via PyErr_WriteUnraisable and returns 0 to C++, and 0 is a perfectly plausible objective value, so the optimizer would carry on and return a confidently wrong answer.

Instead the trampoline catches everything, stores it here, and raises the error flag. The native side unwinds and returns PARAMOPT_CALLBACK_FAILED, and the caller re-raises the stored exception with its original traceback.

Definition at line 425 of file UParameterOptimizationWrapper.py.

Public Member Functions

 __init__ (self)
 

Public Attributes

Optional[Tuple] exception = None
 

Constructor & Destructor Documentation

◆ __init__()

pyhelios.wrappers.UParameterOptimizationWrapper._CallbackState.__init__ ( self)

Definition at line 429 of file UParameterOptimizationWrapper.py.

Member Data Documentation

◆ exception

Optional[Tuple] pyhelios.wrappers.UParameterOptimizationWrapper._CallbackState.exception = None

Definition at line 430 of file UParameterOptimizationWrapper.py.


The documentation for this class was generated from the following file: