summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-03-25 20:23:53 (GMT)
committerGitHub <noreply@github.com>2020-03-25 20:23:53 (GMT)
commit5c3cda0d1a850a1a9b43892f48376b8876bd5863 (patch)
tree723a2cb38dfec21de9cabe70d2bc952986788f5f /Modules
parent0e427c6d159e86f17270770cd8dc37372e3c4004 (diff)
downloadcpython-5c3cda0d1a850a1a9b43892f48376b8876bd5863.zip
cpython-5c3cda0d1a850a1a9b43892f48376b8876bd5863.tar.gz
cpython-5c3cda0d1a850a1a9b43892f48376b8876bd5863.tar.bz2
bpo-39947: Add PyThreadState_GetID() function (GH-19163)
Add PyThreadState_GetID() function: get the unique identifier of a Python thread state.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_asynciomodule.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/Modules/_asynciomodule.c b/Modules/_asynciomodule.c
index 1092b08..c10866a 100644
--- a/Modules/_asynciomodule.c
+++ b/Modules/_asynciomodule.c
@@ -231,7 +231,8 @@ get_running_loop(PyObject **loop)
PyObject *rl;
PyThreadState *ts = PyThreadState_Get();
- if (ts->id == cached_running_holder_tsid && cached_running_holder != NULL) {
+ uint64_t ts_id = PyThreadState_GetID(ts);
+ if (ts_id == cached_running_holder_tsid && cached_running_holder != NULL) {
// Fast path, check the cache.
rl = cached_running_holder; // borrowed
}
@@ -253,7 +254,7 @@ get_running_loop(PyObject **loop)
}
cached_running_holder = rl; // borrowed
- cached_running_holder_tsid = ts->id;
+ cached_running_holder_tsid = ts_id;
}
assert(Py_IS_TYPE(rl, &PyRunningLoopHolder_Type));