Skip to content

Track Runtime run number #1074

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Nov 23, 2021
Prev Previous commit
renamed run system property to __pythonnet_run__ to be consistent wit…
…h other PythonNET properties
  • Loading branch information
lostmsu committed Nov 23, 2021
commit 47b3913843f4d6899277bfed5d31e5080ea4ac97
5 changes: 3 additions & 2 deletions src/runtime/runtime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ internal static Version PyVersion
}
}

const string RunSysPropName = "__pythonnet_run__";
static int run = 0;

internal static int GetRun()
Expand Down Expand Up @@ -142,7 +143,7 @@ internal static void Initialize(bool initSigs = false, ShutdownMode mode = Shutd
PyGILState_Ensure();
}

BorrowedReference pyRun = PySys_GetObject("__pynet_run__");
BorrowedReference pyRun = PySys_GetObject(RunSysPropName);
if (pyRun != null)
{
run = checked((int)PyLong_AsSignedSize_t(pyRun));
Expand Down Expand Up @@ -201,7 +202,7 @@ static void NewRun()
{
run++;
using var pyRun = PyLong_FromLongLong(run);
PySys_SetObject("__pynet_run__", pyRun);
PySys_SetObject(RunSysPropName, pyRun);
}

private static void InitPyMembers()
Expand Down