}
}
+ // TODO GH-121621: This should be moved to PyThreadState
+ // for easier and quicker access.
state->cached_running_loop = rl;
state->cached_running_loop_tsid = ts_id;
}
return -1;
}
+
+ // TODO GH-121621: This should be moved to PyThreadState
+ // for easier and quicker access.
state->cached_running_loop = loop; // borrowed, kept alive by ts_dict
state->cached_running_loop_tsid = PyThreadState_GetID(tstate);
state = get_asyncio_state(module);
}
+ // TODO GH-121621: This should be moved to thread state as well.
if (state && state->fi_freelist_len < FI_FREELIST_MAXLEN) {
state->fi_freelist_len++;
it->future = (FutureObj*) state->fi_freelist;
// optimization: defer task name formatting
// store the task counter as PyLong in the name
// for deferred formatting in get_name
- name = PyLong_FromUnsignedLongLong(++state->task_name_counter);
+#ifdef Py_GIL_DISABLED
+ unsigned long long counter = _Py_atomic_add_uint64(&state->task_name_counter, 1) + 1;
+#else
+ unsigned long long counter = ++state->task_name_counter;
+#endif
+ name = PyLong_FromUnsignedLongLong(counter);
} else if (!PyUnicode_CheckExact(name)) {
name = PyObject_Str(name);
} else {