8000 Improve internal docs · python/cpython@6c594ce · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit 6c594ce

Browse files
committed
Improve internal docs
1 parent 5717f6b commit 6c594ce

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

Include/pythread.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,17 @@ PyAPI_FUNC(void) _Py_NO_RETURN PyThread_exit_thread(void);
2121
PyAPI_FUNC(unsigned long) PyThread_get_thread_ident(void);
2222

2323
#if !defined(Py_LIMITED_API)
24+
/* Thread joining APIs.
25+
*
26+
* These APIs have a strict contract:
27+
* - Either PyThread_join_thread or PyThread_detach_thread must be called
28+
* exactly once with the given handle.
29+
* - Calling neither PyThread_join_thread nor PyThread_detach_thread results
30+
* in a resource leak until the end of the process.
31+
* - Any other usage, such as calling both PyThread_join_thread and
32+
* PyThread_detach_thread, or calling them more than once (including
33+
* simultaneously), results in undefined behavior.
34+
*/
2435
PyAPI_FUNC(unsigned long) PyThread_start_joinable_thread(void (*func)(void *),
2536
void *arg,
2637
Py_uintptr_t* handle);

Modules/_threadmodule.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1280,12 +1280,18 @@ PyDoc_STRVAR(start_new_doc,
12801280
"start_new_thread(function, args[, kwargs[, joinable]])\n\
12811281
(start_new() is an obsolete synonym)\n\
12821282
\n\
1283-
Start a new thread and return its identifier. The thread will call the\n\
1284-
function with positional arguments from the tuple args and keyword arguments\n\
1285-
taken from the optional dictionary kwargs. The thread exits when the\n\
1286-
function returns; the return value is ignored. The thread will also exit\n\
1287-
when the function raises an unhandled exception; a stack trace will be\n\
1288-
printed unless the exception is SystemExit.\n");
1283+
Start a new thread and return its identifier.\n\
1284+
\n\
1285+
The thread will call the function with positional arguments from the\n\
1286+
tuple args and keyword arguments taken from the optional dictionary\n\
1287+
kwargs. The thread exits when the function returns; the return value\n\
1288+
is ignored. The thread will also exit when the function raises an\n\
1289+
unhandled exception; a stack trace will be printed unless the exception\n\
1290+
is SystemExit.\n\
1291+
If the optional joinable argument is True, then the thread must later\n\
1292+
be joined with join_thread() or detached with detach_thread().\n\
1293+
Failure to do so results in a system resource leak until interpreter\n\
1294+
shutdown.\n");
12891295

12901296
static PyObject *
12911297
thread_PyThread_exit_thread(PyObject *self, PyObject *Py_UNUSED(ignored))

0 commit comments

Comments
 (0)
0