Untitled
Anonymous
plain_text
03/23/2023 8:43 AM
1.0 KB
18
Indexable
PythonEngine.Initialize();
using (Py.GIL())
{
PythonEngine.RunString($"print('Python yes' + str({55}))");
}
// Create 4 tasks, each with their own Python interpreter
var tasks = new Task[4];
for (int i = 0; i < tasks.Length; i++)
{
tasks[i] = Task.Run(() =>
{
using (Py.GIL())
{
PythonEngine.RunString($"print('Python yes' + str({55}))");
}
});
}
// Wait for all tasks to complete
Task.WaitAll(tasks);
// Shut down the Python runtime
PythonEngine.Shutdown();Editor is loading...