python-greenlet / greenlet

Lightweight in-process concurrent programming
Other
1.63k stars 247 forks source link

Missing _thread._is_main_interpreter() #390

Closed ericsnowcurrently closed 8 months ago

ericsnowcurrently commented 9 months ago

(See https://github.com/python/cpython/issues/112826.)

In the CPython main branch (i.e. 3.13+), as of https://github.com/python/cpython/pull/112661, the threading module expects the _thread module to provide _is_main_interpreter(). Apparently it doesn't.

I'd like to make sure that gets fixed as soon as possible. I'd be glad to open a PR but it would help to first have some instruction on where to look for the relevant code.

FYI, the same expectation applies with the upcoming CPython 3.12.1 release, as of https://github.com/python/cpython/pull/110707.

jamadden commented 9 months ago

Maybe you're thinking of gevent? greenlet doesn't modify or replace any stdlib modules.

ericsnowcurrently commented 9 months ago

Hmm, I'm going off of what someone reported on https://github.com/python/cpython/issues/112826. I didn't look too closely though. I'll double-check. Thanks for the pointer.

jamadden commented 8 months ago

I can confirm that is an eventlet-specific problem. Neither greenlet nor gevent messes with that attribute.

$ python -c 'import sys; import gevent.monkey; import _thread; print(sys.version); gevent.monkey.patch_all(); print(_thread._is_main_interpreter)'
3.12.1 (main, Dec 12 2023, 13:05:57) [Clang 15.0.0 (clang-1500.1.0.2.5)]
<built-in function _is_main_interpreter>
ericsnowcurrently commented 8 months ago

thanks for looking that up

jamadden commented 8 months ago

Thanks for the heads-up!