From fff7bbfdb6b7c143b73b6b4b6b40e828c101110c Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Wed, 20 Nov 2019 17:34:39 +0100 Subject: bpo-38858: Add _Py_IsMainInterpreter(tstate) (GH-17293) --- Python/pystate.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'Python/pystate.c') diff --git a/Python/pystate.c b/Python/pystate.c index 2fc563bf58..0a6d035836 100644 --- a/Python/pystate.c +++ b/Python/pystate.c @@ -159,6 +159,12 @@ _PyRuntimeState_ReInitThreads(_PyRuntimeState *runtime) #define HEAD_UNLOCK(runtime) \ PyThread_release_lock((runtime)->interpreters.mutex) +int +_Py_IsMainInterpreter(PyThreadState* tstate) +{ + return (tstate->interp == tstate->interp->runtime->interpreters.main); +} + /* Forward declaration */ static void _PyGILState_NoteThreadState( struct _gilstate_runtime_state *gilstate, PyThreadState* tstate); -- cgit v1.2.1