clr-loader icon indicating copy to clipboard operation
clr-loader copied to clipboard

Deadlock calling pythonnet.set_runtime twice

Open sschukat opened this issue 2 years ago • 1 comments

With the update to delay the load of the runtime from 0.25 to 0.26 a deadlock occurs with following code

import pythonnet
pythonnet.set_runtime("coreclr")
pythonnet.set_runtime("coreclr")

This is explicit a problem of the core clr. We did not see that with .NET FF.

We tracked it down to https://github.com/pythonnet/clr-loader/blob/a88b6a1a0086278e3518f373487ae8819023cb2e/clr_loader/hostfxr.py#L135

this function deadlocks the second time called if https://github.com/pythonnet/clr-loader/blob/a88b6a1a0086278e3518f373487ae8819023cb2e/clr_loader/hostfxr.py#L146

was not called before.

sschukat avatar Aug 30 '23 07:08 sschukat

Thank you for the report, I'll look into it. It's probably enough to force finishing up the initialization in set_runtime instead of keeping it in limbo until load is called.

filmor avatar Aug 30 '23 10:08 filmor