NUnit Embedded tests fail occasionally on Python3

Environment

  • Pythonnet version: Current
  • Python version: 3.3+
  • Operating System: Windows

Details

  • Describe what you were trying to get done.

Run Unit tests on AppVeyor

  • If there was a crash, please include the traceback here.
Execution Runtime: net-3.5
OpenCover.Console.exe : 
At C:\projects\pythonnet\ci\appveyor_run_tests.ps1:22 char:1
+ .$OPENCOVER -register:user -searchdirs:"$RUNTIME_DIR" -output:cs.cove ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError
 
Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
   at Python.Runtime.Runtime.PyGILState_Ensure()
   at Python.Runtime.PythonEngine.AcquireLock() in C:\projects\pythonnet\src\runtime\pythonengine.cs:line 309
   at Python.Runtime.PyObject.Dispose(Boolean disposing) in C:\projects\pythonnet\src\runtime\pyobject.cs:line 118
   at Python.Runtime.PyObject.Dispose() in C:\projects\pythonnet\src\runtime\pyobject.cs:line 129
   at Python.Runtime.PyObject.Finalize() in C:\projects\pythonnet\src\runtime\pyobject.cs:line 46
Fatal Python error: take_gil: NULL tstate
...F.Unhandled Exception:

Possibly related

https://bugs.python.org/issue26003
https://bugs.python.org/issue19576
https://bugs.python.org/issue20891
http://stackoverflow.com/questions/4866701/python-pygilstate-ensure-release-causes-segfault-while-returning-to-c-from-p