pythonnet: Crash when file or folder from import gets modified (Memory Corrupt...)

Environment

  • Pythonnet version: 2.5.1
  • Python version: 3.8
  • Operating System: Win10, WinServer (2019,2016)
  • .NET Runtime: 4.7

Details

  • Describe what you were trying to get done. I have a webservice that invokes a python.py file and gets its result, it works fine, the webservice is hosted in IIS, however whenever I change something from the file or folder where the python file I imported is it corrupts the memory and I have to restart the app pool or restart iis, To import the file I just use: Py.Import(INTERFACE_FILE_NAME); Is there some fundamental thing I’m missing?

    This is the error message I get, it seems to be crashing when the .py file has been modified and it tries import it again. :

System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. at Python.Runtime.Runtime.PyImport_ImportModule(String name) at Python.Runtime.Runtime.Initialize(Boolean initSigs) at Python.Runtime.PythonEngine.Initialize(IEnumerable`1 args, Boolean setSysArgv, Boolean initSigs) at Python.Runtime.PythonEngine.Initialize()

What I’ve tried:

What hasn’t worked: Py.Import PyModule.FromString (Access Violations…)

What has worked: Using any of the import methods but stopping the app pool, editing file and restarting the app pool (I don’t like this option)

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 19 (8 by maintainers)

Most upvoted comments

Could you test whether this occurs on the current master as well?