GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — C API: Design an API to disallow creating more than one extension instance per Python process · Issue #111088 · python/cpython Closed Labels DescriptionSomewhere in Or maybe the restriction should be that an extension cannot be loaded in two different interpreters. Honestly, I'm not sure. @ericsnowcurrently no longer wants to treat the main interpreter differently: see issue gh-109857. Previously, I proposed to directly expose PyInterpreterState_IsMain() to the limited C API, but the idea got rejected. The syslog module behaves differently if it's used in the main interpreter: static inline int is_main_interpreter(void) { return (PyInterpreterState_Get() == PyInterpreterState_Main()); } ... if (!is_main_interpreter()) { PyErr_SetString(PyExc_RuntimeError, "subinterpreter can't use syslog.openlog()"); return NULL; } The syslog module stores a Python object in See issue gh-99127 and PR gh-99128 which added Cython already implements a similar, but different check: it raises "this module can only be loaded into one interpreter per process" error message. Cython uses a different logic to handle PEP 489 "Multi-phase extension module initialization". It uses a //#if CYTHON_PEP489_MULTI_PHASE_INIT static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) { #if PY_VERSION_HEX >= 0x030700A1 static PY_INT64_T main_interpreter_id = -1; PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp); if (main_interpreter_id == -1) { main_interpreter_id = current_id; return (unlikely(current_id == -1)) ? -1 : 0; } else if (unlikely(main_interpreter_id != current_id)) #else static PyInterpreterState *main_interpreter = NULL; PyInterpreterState *current_interpreter = PyThreadState_Get()->interp; if (!main_interpreter) { main_interpreter = current_interpreter; } else if (unlikely(main_interpreter != current_interpreter)) #endif { PyErr_SetString( PyExc_ImportError, "Interpreter change detected - this module can only be loaded into one interpreter per process."); return -1; } return 0; } Activity
MetadataMetadataAssigneesLabelsProjectsMilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |