-
-
Notifications
You must be signed in to change notification settings - Fork 31k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gh-112535: Add test on _Py_ThreadId() #112709
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1625,6 +1625,17 @@ get_type_module_name(PyObject *self, PyObject *type) | |
} | ||
|
||
|
||
#ifdef Py_GIL_DISABLED | ||
static PyObject * | ||
get_py_thread_id(PyObject *self, PyObject *Py_UNUSED(ignored)) | ||
{ | ||
uintptr_t tid = _Py_ThreadId(); | ||
Py_BUILD_ASSERT(sizeof(unsigned long long) >= sizeof(tid)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can just use C11 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Py_BUILD_ASSERT() doesn't require an error message which makes my life easier, I don't have to write down an error message :-) |
||
return PyLong_FromUnsignedLongLong(tid); | ||
} | ||
#endif | ||
|
||
|
||
static PyMethodDef module_functions[] = { | ||
{"get_configs", get_configs, METH_NOARGS}, | ||
{"get_recursion_depth", get_recursion_depth, METH_NOARGS}, | ||
|
@@ -1688,6 +1699,9 @@ static PyMethodDef module_functions[] = { | |
{"restore_crossinterp_data", restore_crossinterp_data, METH_VARARGS}, | ||
_TESTINTERNALCAPI_TEST_LONG_NUMBITS_METHODDEF | ||
{"get_type_module_name", get_type_module_name, METH_O}, | ||
#ifdef Py_GIL_DISABLED | ||
{"py_thread_id", get_py_thread_id, METH_NOARGS}, | ||
#endif | ||
{NULL, NULL} /* sentinel */ | ||
}; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vstinner - looks like Windows tests are failing (possibly due to missing import for support:
https://github.com/python/cpython/actions/runs/7090430380/job/19297369118?pr=112709
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah right, I saw it before. Thanks for the reminder. It should now be fixed.