What can slow down/block python.net calls?

135 views Asked by At

I am using python.net to import a python module in C#. Everything worked well until recently when I experienced dramatic slow down on module import. Nothing changed on the machine other then Windows updates and McAfee updates. I am suspecting Windows Defender or McAfee to block the python.net bridge but any clue or previous experience to solve this issue is welcome. I am working locally so its not a shared drive issue.

Here is a reproducible example in c#:

    PythonEngine.Initialize();

    using (Py.GIL())
    {
        PythonScope = Py.CreateScope();

        PythonScope.Exec("import numpy as np");  //this line recently takes forever (> 15 sec !!!) 
    }

So here I show numpy package import as example. The interesting thing is that if I time the import of this package in Git Batch before and after the C# call, you can also see the dramatic difference:

Git Batch snapshot

Then if I wait a bit, and try the import in Git Batch again, it comes back to normal. So there is something very odd going on with python.net. Any advice/clue on what is causing this would be welcome.

1

There are 1 answers

0
bricx On

McAfee Adaptive Threat Protection is blocking python.net calls. You need to disable it in order to work with python.net.