Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ceaaef0

Browse files
committed
fixup! create unnamed pyscope, make PyScope.GILState save
1 parent b0d57e9 commit ceaaef0

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/runtime/pythonengine.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,6 @@ public void Dispose()
573573
return;
574574
}
575575
isDisposed = true;
576-
AcquireLock();
577576
ReleaseLock();
578577
GC.SuppressFinalize(this);
579578
}
@@ -957,7 +956,10 @@ public virtual void Dispose()
957956
AcquireLock();
958957
Runtime.XDecref(globals);
959958
Runtime.XDecref(locals);
960-
Py.RemoveSession(this);
959+
if(this.Parent == null)
960+
{
961+
Py.RemoveSession(this);
962+
}
961963
isDisposed = true;
962964
}
963965

@@ -1010,7 +1012,7 @@ public static PyScope Session(string name = null)
10101012

10111013
internal static void RemoveSession(PyScope scope)
10121014
{
1013-
if(scope.Parent == null)//top session
1015+
if(scope.Parent == null)//top scope
10141016
{
10151017
Sessions.Remove(scope);
10161018
if(scope.Name != null)

0 commit comments

Comments
 (0)