GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Make `_threadmodule.c` thread-safe in `--disable-gil` builds · Issue #114271 · python/cpython

Make _threadmodule.c thread-safe in --disable-gil builds #114271

New issue
Copy link
New issue
Copy link
Closed
Closed
Make _threadmodule.c thread-safe in --disable-gil builds#114271
Copy link
Assignees
mpage
Labels
topic-free-threadingtype-featureA feature request or enhancementA feature request or enhancement

Description

@mpage
mpage
opened on Jan 18, 2024
Issue body actions

Feature or enhancement

Proposal:

Make the functionality in _threadmodule.c thread-safe in free-threaded builds.

Commits from nogil-3.12: https://github.com/colesbury/nogil-3.12/commits/nogil-3.12/Modules/_threadmodule.c

Context from @colesbury:

  • Ignore the CriticalLock commit; this was an idea that didn't work and was prone to deadlock.
  • Ignore the weakrefs change.
  • Unclear if we need to deal with _tstate_lock.
  • For the other changes, use your judgement. You may be able to put together smaller changes
  • _Py_ThreadId() is currently only available in the free-threaded build, so the recursive lock implementation can probably (?) just stick with the existing PyThread_get_thread_ident().

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Linked PRs

  • gh-114271: Fix race in Thread.join() #114839
  • gh-114271: Make PyInterpreterState.threads.count thread-safe in free-threaded builds #115093
  • gh-114271: Make thread._rlock thread-safe in free-threaded builds #115102
  • gh-114271: Make _thread.ThreadHandle thread-safe in free-threaded builds #115190
  • gh-114271: Make _thread.lock thread-safe in free-threaded builds #116433
  • gh-114271: Clean Up _threadmodule.c #116776

Activity

Next
  1. mpage
    added
    type-featureA feature request or enhancementA feature request or enhancement
    on Jan 18, 2024
  2. Eclips4
    added
    topic-free-threading
    on Jan 19, 2024
  3. mpage commented on Jan 19, 2024

    @mpage
    mpage
    on Jan 19, 2024
    ContributorAuthor
    More actions

    @colesbury - Would you assign this to me, please?

    Reacted by Sam Gross
  4. colesbury
    assigned
    mpage
    on Jan 19, 2024
  5. mpage
    added a commit that references this issue on Feb 5, 2024

    Merge branch 'main' into pythongh-114271-remove-tstate_lock

    19d7af1
  6. ericsnowcurrently
    added a commit that references this issue on Feb 12, 2024

    gh-114271: Make `PyInterpreterState.threads.count` thread-safe in fre…

    de7d67b
  7. fsc-eriker
    added a commit that references this issue on Feb 14, 2024

    pythongh-114271: Make `PyInterpreterState.threads.count` thread-safe …

    c62acde
  8. mpage
    added 5 commits that reference this issue on Feb 16, 2024

    Merge branch 'main' into pythongh-114271-remove-tstate_lock

    c86d349

    Merge branch 'main' into pythongh-114271-remove-tstate_lock

    40e4b36

    Merge branch 'main' into pythongh-114271-remove-tstate_lock

    4ed1083

    Merge branch 'main' into pythongh-114271-_thread-ThreadHandle

    9ec6d23

    Merge branch 'pythongh-114271-_thread-ThreadHandle' into pythongh-11427…

    012ea77
  9. colesbury
    added a commit that references this issue on Feb 16, 2024

    gh-114271: Make `thread._rlock` thread-safe in free-threaded builds (#…

    f366e21
  10. gpshead
    added a commit that references this issue on Mar 1, 2024

    gh-114271: Make `_thread.ThreadHandle` thread-safe in free-threaded b…

    9e88173
  11. woodruffw
    added a commit that references this issue on Mar 4, 2024

    pythongh-114271: Make `thread._rlock` thread-safe in free-threaded bu…

    fe3c2ff
  12. 15 remaining items

  13. vstinner
    added a commit that references this issue on Mar 20, 2024

    pythongh-114271: Fix race in `Thread.join()` (python#114839)

    a71f637
  14. adorilson
    added 3 commits that reference this issue on Mar 25, 2024

    pythongh-114271: Make `_thread.ThreadHandle` thread-safe in free-thre…

    d69e884

    pythongh-114271: Make `_thread.lock` thread-safe in free-threaded bui…

    7ae28cb

    pythongh-114271: Fix race in `Thread.join()` (python#114839)

    1a0dba1
  15. colesbury commented on Apr 10, 2024

    @colesbury
    colesbury
    on Apr 10, 2024
    Contributor
    More actions

    @mpage is this complete?

  16. mpage commented on Apr 10, 2024

    @mpage
    mpage
    on Apr 10, 2024
    ContributorAuthor
    More actions

    Yep. I filed #117721 to track the follow up work we discussed for _thread.lock.release().

  17. mpage
    closed this as completedon Apr 10, 2024
  18. diegorusso
    added 4 commits that reference this issue on Apr 17, 2024

    pythongh-114271: Make `thread._rlock` thread-safe in free-threaded bu…

    8281fa1

    pythongh-114271: Make `_thread.ThreadHandle` thread-safe in free-thre…

    bf25f87

    pythongh-114271: Make `_thread.lock` thread-safe in free-threaded bui…

    5cab8ec

    pythongh-114271: Fix race in `Thread.join()` (python#114839)

    faaa555
  19. stefanor
    added 2 commits that reference this issue on Nov 7, 2024

    _tstate_lock was removed in Python 3.13

    969cd8d

    _tstate_lock was removed in Python 3.13

    619fe81
  20. 4383
    added a commit that references this issue on Nov 15, 2024

    Python 3.13 Support (#988)

    4d48d10
  21. LukasWoodtli
    added a commit that references this issue on Jan 22, 2025

    pythongh-114271: Make `thread._rlock` thread-safe in free-threaded bu…

    2c6a82b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @mpage
    mpage

Labels

topic-free-threadingtype-featureA feature request or enhancementA feature request or enhancement

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue 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.