-
Notifications
You must be signed in to change notification settings - Fork 188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dyn-6672 - python engines failing to load should not stop Dynamo from starting #3040
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
using System.Collections.Generic; | ||
using System.Collections.Specialized; | ||
using System.Diagnostics; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Windows.Forms; | ||
using Autodesk.Revit.DB; | ||
|
@@ -443,9 +444,16 @@ private void SetupPythonEngine(PythonEngine engine) | |
{ | ||
if (engine != null) | ||
{ | ||
(engine.OutputDataMarshaler as DataMarshaler).RegisterMarshaler((Element element) => element.ToDSType(true)); | ||
engine.EvaluationStarted += OnPythonEvalStart; | ||
engine.EvaluationFinished += OnPythonEvalFinished; | ||
try | ||
{ | ||
(engine.OutputDataMarshaler as DataMarshaler).RegisterMarshaler((Element element) => element.ToDSType(true)); | ||
engine.EvaluationStarted += OnPythonEvalStart; | ||
engine.EvaluationFinished += OnPythonEvalFinished; | ||
} | ||
catch(FileNotFoundException ex) | ||
{ | ||
Logger.Log(ex); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I really wish there was a DynamoCore way to ensure that all PythonEngine public APIs are safe to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You cannot even mark an event as "Can throw Exception of type X". Oh we can...if that is any comfort There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @pinzart90 I am looking into something on the DynamoCore side, I will send another PR for feedback on that. More a spike than something real at this point. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a way to propagate the error in DynamoCore and display it to the user somehow? |
||
} | ||
} | ||
|
||
|
@@ -455,11 +463,18 @@ private void SetupPythonEngine(PythonEngine engine) | |
/// <param name="engine"></param> | ||
private void CleanUpPythonEngine(PythonEngine engine) | ||
{ | ||
if (engine != null) | ||
try | ||
{ | ||
if (engine != null) | ||
{ | ||
(engine.OutputDataMarshaler as DataMarshaler).UnregisterMarshalerOfType<Element>(); | ||
engine.EvaluationStarted -= OnPythonEvalStart; | ||
engine.EvaluationFinished -= OnPythonEvalFinished; | ||
} | ||
} | ||
catch (FileNotFoundException ex) | ||
{ | ||
(engine.OutputDataMarshaler as DataMarshaler).UnregisterMarshalerOfType<Element>(); | ||
engine.EvaluationStarted -= OnPythonEvalStart; | ||
engine.EvaluationFinished -= OnPythonEvalFinished; | ||
Logger.Log(ex); | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this file was deleted previously.