Skip to content

[WIP][Workaround] Skip ident comparison to avoid crash on Python 3.13+#1031

Closed
4383 wants to merge 2 commits into
eventlet:masterfrom
4383:gil-and-threads-ident
Closed

[WIP][Workaround] Skip ident comparison to avoid crash on Python 3.13+#1031
4383 wants to merge 2 commits into
eventlet:masterfrom
4383:gil-and-threads-ident

Conversation

@4383

@4383 4383 commented Mar 28, 2025

Copy link
Copy Markdown
Member

Python 3.13 introduced major internal changes to thread management as part of PEP 703 (GIL removal), including native thread handles and joinable threads. These changes modified how thread identifiers are defined and used in the standard library, breaking compatibility with Eventlet's monkey-patched threading model.

The issue decribed in #1030 is related to the GIL and PEP 703 because Python 3.13 introduced internal thread handles and joinable threads to support the no-GIL mode, changing how thread identifiers are managed: instead of simple values, they are now internal native identifiers handled at the C level, tied to OS-level threads or new CPython thread structures.

Since Eventlet is deeply tied to green threads and emulates standard threads using greenlet-based constructs, properly adapting to Python 3.13 would require a near-complete rewrite of its threading logic.

As a temporary workaround, this commit skips the comparison of thread identifiers to avoid AttributeErrors and restore partial functionality under Python 3.13+.

A full fix will need a deeper architectural review.

Related to #1030

@4383
4383 requested a review from itamarst March 28, 2025 15:02
@codecov

codecov Bot commented Mar 28, 2025

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 0% with 25 lines in your changes missing coverage. Please review.

Project coverage is 55%. Comparing base (3ec6317) to head (8815c8a).

Files with missing lines Patch % Lines
eventlet/green/thread.py 0% 24 Missing and 1 partial ⚠️
Additional details and impacted files
@@          Coverage Diff           @@
##           master   #1031   +/-   ##
======================================
- Coverage      56%     55%   -1%     
======================================
  Files          89      89           
  Lines        9852    9868   +16     
  Branches     1772    1774    +2     
======================================
- Hits         5575    5523   -52     
- Misses       3913    3983   +70     
+ Partials      364     362    -2     
Flag Coverage Δ
ipv6 22% <0%> (-1%) ⬇️
py310asyncio 53% <0%> (-2%) ⬇️
py310epolls 53% <0%> (-2%) ⬇️
py310poll 53% <0%> (-2%) ⬇️
py310selects 53% <0%> (-2%) ⬇️
py311asyncio 53% <0%> (-2%) ⬇️
py311epolls 53% <0%> (-2%) ⬇️
py312asyncio ?
py312epolls ?
py313asyncio ?
py313epolls ?
py38asyncio 51% <0%> (-2%) ⬇️
py38epolls 53% <0%> (-2%) ⬇️
py38openssl 51% <0%> (-2%) ⬇️
py38poll 53% <0%> (-2%) ⬇️
py38selects 52% <0%> (-2%) ⬇️
py39asyncio 51% <0%> (-2%) ⬇️
py39dnspython1 51% <0%> (-2%) ⬇️
py39epolls 53% <0%> (-2%) ⬇️
py39poll 53% <0%> (-2%) ⬇️
py39selects 53% <0%> (-2%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Python 3.13 introduced major internal changes to thread management as part of
PEP 703 (GIL removal), including native thread handles and joinable threads.
These changes modified how thread identifiers are defined and used in the
standard library, breaking compatibility with Eventlet's monkey-patched
threading model.

The issue decribed in eventlet#1030 is related to the GIL and PEP 703 because
Python 3.13 introduced internal thread handles and joinable threads to
support the no-GIL mode, changing how thread identifiers are managed:
instead of simple values, they are now internal native identifiers handled
at the C level, tied to OS-level threads or new CPython thread structures.

Since Eventlet is deeply tied to green threads and emulates standard threads
using greenlet-based constructs, properly adapting to Python 3.13 would
require a near-complete rewrite of its threading logic.

As a temporary workaround, this commit skips the comparison of thread
identifiers to avoid AttributeErrors and restore partial functionality under
Python 3.13+.

A full fix will need a deeper architectural review.

Related to eventlet#1030

@itamarst itamarst left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you include some sort of test that passes now and failed previously? So at least we know we're not regressing if we have to make future changes.

@4383

4383 commented Apr 29, 2025

Copy link
Copy Markdown
Member Author

Sure, will do that.

@4383 4383 mentioned this pull request May 12, 2025
@4383

4383 commented May 14, 2025

Copy link
Copy Markdown
Member Author

Well, I think we have many problems here.

The first one is that I think our recent job refactor was a bit invasive and apparently we accidentally removed all the jobs execution, tests are missing. So I think we have to restore a transient version of our previous github actions to restore the execution of our unit tests.

The second one is that this patch broke more 40 unit tests (local run), but in parallel it fix the reproducer shared with us in the issue. Both kind of tests should execute successfully. So this patch need further works or another approach to manage the reproducer.

@4383 4383 changed the title [Workaround] Skip ident comparison to avoid crash on Python 3.13+ [WIP][Workaround] Skip ident comparison to avoid crash on Python 3.13+ May 14, 2025
@itamarst

Copy link
Copy Markdown
Contributor

I have come up with a more fundamental solution for #1030, at least.

@itamarst itamarst closed this Jun 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants