Browse Source

Add async Eval method to PyRunner

pull/5/head
Ionite 2 years ago
parent
commit
b338ad82a5
No known key found for this signature in database
  1. 15
      StabilityMatrix/PyRunner.cs

15
StabilityMatrix/PyRunner.cs

@ -46,5 +46,18 @@ internal static class PyRunner
sys.stderr = StdErrStream; sys.stderr = StdErrStream;
} }
}); });
} }
// Evaluate Python code
public static async Task<string> Eval(string code)
{
using (Py.GIL())
{
return await Task.Run(() =>
{
dynamic result = PythonEngine.Eval(code);
return result.ToString();
});
}
}
} }
Loading…
Cancel
Save