Skip to content

socketmodule.c: use atomics to access defaulttimeout in free-threaded build  #116616

Closed
@colesbury

Description

@colesbury

Feature or enhancement

The defaulttimeout in socketmodule.c is shared, mutable state:

PyTime_t defaulttimeout;

In the free-threaded build, we should use relaxed atomic operations to access defaulttimeout to avoid data races. This probably requires adding wrappers for 64-bit relaxed atomic load and stores to https://github.com/python/cpython/blob/main/Include/internal/pycore_pyatomic_ft_wrappers.h. Note that _PyTime_t is a typedef for int64_t.

For context, here is a similar change from nogil-3.12, but note that defaulttimeout is now part of the module state:

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions