PEP 768 and embedding Python

When embedding a Python interpreter using the Python C API, _PyInterpreterState_SetRunningMain doesn’t get called as part of initializing the interpreter, and is not available as a public API.

Attempting to debug using “python -m pdb -p XX” fails with “Can’t find the main thread in the remote process” as the interpreter threads.main isn’t set.

What’s the best way to set this when initializing Python so that the new remote debugger feature works correctly?

Possibly related to `test.test_interpreters.test_api.TestInterpreterIsRunning.test_main` Fails in Embedded App · Issue #115482 · python/cpython · GitHub and gh-115482: Assume the Main Interpreter is Always Running "main" by ericsnowcurrently · Pull Request #115484 · python/cpython · GitHub

Thanks!
Tony

FWIW, after calling the non-public _PyInterpreterState_SetRunningMain function, everything seems fine. Maybe this should optionally be called as part of Py_InitializeFromConfig, with some ‘is main’ flag on the config perhaps?