Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Make hashlib related modules thread-safe without the GIL #111916

Closed
Assignees
tomasr8
@colesbury

Description

@colesbury

Feature or enhancement

The hashlib based modules already have some locking to make some operations thread-safe (with the GIL), but the logic isn't sufficient if running with the GIL disabled.

Relevant files:

  • Modules/_blake2/blake2b_impl.c
  • Modules/_blake2/blake2s_impl.c
  • Modules/_hashopenssl.c
  • Modules/hashlib.h
  • Modules/md5module.c
  • Modules/sha1module.c
  • Modules/sha2module.c
  • Modules/sha3module.c

Basic idea:

  1. ReplacePyThread_type_lock lock withPyMutex. This should be both simpler and faster in general and avoid the need for dynamically assigning a lock, which can pose thread-safety issues without the GIL
  2. Add a fieldbool use_mutex to indicate if the code should lock the mutex. This should always be set totrue inPy_NOGIL. In the default build, we should dynamically set it totrue in places where we previously allocatedself->lock
  3. UpdateENTER_HASHLIB andEXIT_HASHLIB macros.

Linked PRs

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp