Skip to content

Commit

Permalink
Update PythonServices.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
pinzart90 committed Feb 14, 2024
1 parent 395f9fa commit 75016e0
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions src/NodeServices/PythonServices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,24 +126,22 @@ internal static readonly Lazy<PythonEngineManager>
private Action<PythonEngine> customizeEngine;

/// <summary>
/// Use this function to customize Python engine initialization.
/// This function will be called only once on all existing or future python engines (on PythonEngineAdded).
/// Provides an easy way to run initialization code on PythonEngine instances
/// </summary>
public Action<PythonEngine> CustomizeEngine
/// <param name="initAction">Action to be called on PythonEngines.</param>
/// <param name="callOnExistingEngines">If true, the action will be called on existing PythonEngines. If false the action will be called when new Python engines are added.</param>
public void ApplyInitializationAction(Action<PythonEngine> initAction, bool callOnExistingEngines = true)
{
set
if (initAction != null)
{
customizeEngine = value;
if (customizeEngine != null)
customizeEngine = initAction;

if (callOnExistingEngines)
{
try
foreach (var engine in AvailableEngines)
{
foreach (var engine in AvailableEngines)
{
customizeEngine(engine);
}
initAction(engine);
}
catch { }
}
}
}
Expand Down

0 comments on commit 75016e0

Please sign in to comment.