Skip to content

Commit d7dd332

Browse files
committed
gh-155628: Use a relaxed add for the asyncio task name counter
The counter only generates unique default Task names; the add is its sole access in the free-threaded build, so only the uniqueness of each returned value matters, which atomicity alone guarantees.
1 parent 6510577 commit d7dd332

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

Modules/_asynciomodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2342,7 +2342,7 @@ _asyncio_Task___init___impl(TaskObj *self, PyObject *coro, PyObject *loop,
23422342
// store the task counter as PyLong in the name
23432343
// for deferred formatting in get_name
23442344
#ifdef Py_GIL_DISABLED
2345-
unsigned long long counter = _Py_atomic_add_uint64(&state->task_name_counter, 1) + 1;
2345+
unsigned long long counter = _Py_atomic_add_uint64_relaxed(&state->task_name_counter, 1) + 1;
23462346
#else
23472347
unsigned long long counter = ++state->task_name_counter;
23482348
#endif

0 commit comments

Comments
 (0)