summaryrefslogtreecommitdiffstats
path: root/Python/thread.c
Commit message (Collapse)AuthorAgeFilesLines
* gh-110850: Cleanup PyTime API: PyTime_t are nanoseconds (#115753)Victor Stinner2024-02-211-2/+2
| | | | | | | | | | PyTime_t no longer uses an arbitrary unit, it's always a number of nanoseconds (64-bit signed integer). * Rename _PyTime_FromNanosecondsObject() to _PyTime_FromLong(). * Rename _PyTime_AsNanosecondsObject() to _PyTime_AsLong(). * Remove pytime_from_nanoseconds(). * Remove pytime_as_nanoseconds(). * Remove _PyTime_FromNanoseconds().
* gh-110850: Replace _PyTime_t with PyTime_t (#115719)Victor Stinner2024-02-201-3/+3
| | | | | Run command: sed -i -e 's!\<_PyTime_t\>!PyTime_t!g' $(find -name "*.c" -o -name "*.h")
* gh-84570: Add Timeouts to SendChannel.send() and RecvChannel.recv() (gh-110567)Eric Snow2023-10-171-0/+34
|
* gh-84570: Send-Wait Fixes for _xxinterpchannels (gh-111006)Eric Snow2023-10-171-0/+50
| | | | | There were a few things I did in gh-110565 that need to be fixed. I also forgot to add tests in that PR. (Note that this PR exposes a refleak introduced by gh-110246. I'll take care of that separately.)
* gh-110014: Fix _POSIX_THREADS and _POSIX_SEMAPHORES usage (#110139)Victor Stinner2023-09-301-1/+21
| | | | | | | | | | | | | | | | * pycore_pythread.h is now the central place to make sure that _POSIX_THREADS and _POSIX_SEMAPHORES macros are defined if available. * Make sure that pycore_pythread.h is included when _POSIX_THREADS and _POSIX_SEMAPHORES macros are tested. * PY_TIMEOUT_MAX is now defined as a constant, since its value depends on _POSIX_THREADS, instead of being defined as a macro. * Prevent integer overflow in the preprocessor when computing PY_TIMEOUT_MAX_VALUE on Windows: replace "0xFFFFFFFELL * 1000 < LLONG_MAX" with "0xFFFFFFFELL < LLONG_MAX / 1000". * Document the change and give hints how to fix affected code. * Add an exception for PY_TIMEOUT_MAX name to smelly.py * Add PY_TIMEOUT_MAX to the stable ABI
* gh-108765: Cleanup #include in Python/*.c files (#108977)Victor Stinner2023-09-061-1/+1
| | | Mention one symbol imported by each #include.
* gh-94673: Properly Initialize and Finalize Static Builtin Types for Each ↵Eric Snow2023-05-021-6/+3
| | | | | Interpreter (gh-104072) Until now, we haven't been initializing nor finalizing the per-interpreter state properly.
* gh-84436: Immortalize in _PyStructSequence_InitBuiltinWithFlags() (gh-104054)Eric Snow2023-05-011-2/+2
| | | This also does some cleanup.
* gh-94673: Ensure Builtin Static Types are Readied Properly (gh-103940)Eric Snow2023-04-271-4/+2
| | | There were cases where we do unnecessary work for builtin static types. This also simplifies some work necessary for a per-interpreter GIL.
* gh-81057: Move Threading-Related Globals to _PyRuntimeState (#100084)Eric Snow2022-12-091-30/+6
| | | https://github.com/python/cpython/issues/81057
* gh-99300: Use Py_NewRef() in Python/ directory (#99302)Victor Stinner2022-11-101-2/+1
| | | | Replace Py_INCREF() and Py_XINCREF() with Py_NewRef() and Py_XNewRef() in C files of the Python/ directory.
* gh-96125: Fix sys.thread_info.name on pthread platforms (GH-96126)Christian Heimes2022-08-191-1/+1
| | | Automerge-Triggered-By: GH:tiran
* gh-95174: Add pthread stubs for WASI (GH-95234)Christian Heimes2022-07-271-5/+13
| | | Co-authored-by: Brett Cannon <brett@python.org>
* gh-94673: Add _PyStaticType_InitBuiltin() (#95152)Eric Snow2022-07-251-1/+2
| | | | | | | | | | | | This is the first of several precursors to storing tp_subclasses (and tp_weaklist) on the interpreter state for static builtin types. We do the following: * add `_PyStaticType_InitBuiltin()` * add `_Py_TPFLAGS_STATIC_BUILTIN` * set it on all static builtin types in `_PyStaticType_InitBuiltin()` * shuffle some code around to be able to use _PyStaticType_InitBuiltin() * rename `_PyStructSequence_InitType()` to `_PyStructSequence_InitBuiltinWithFlags()` * add `_PyStructSequence_InitBuiltin()`.
* gh-88750: Remove the PYTHONTHREADDEBUG env var support. (#92509)Gregory P. Smith2022-05-091-38/+0
| | | | Remove the `PYTHONTHREADDEBUG` env var support. Remove no-op dprintf() macro calls.
* bpo-46670: Remove unused macros in the Python directory (GH-31192)Victor Stinner2022-02-071-4/+2
|
* bpo-46417: _curses uses PyStructSequence_NewType() (GH-30736)Victor Stinner2022-01-211-1/+2
| | | | | | | | The _curses module now creates its ncurses_version type as a heap type using PyStructSequence_NewType(), rather than using a static type. * Move _PyStructSequence_FiniType() definition to pycore_structseq.h. * test.pythoninfo: log curses.ncurses_version.
* bpo-46417: Finalize structseq types at exit (GH-30645)Victor Stinner2022-01-211-0/+11
| | | | | | | | | | | | | | | | | | Add _PyStructSequence_FiniType() and _PyStaticType_Dealloc() functions to finalize a structseq static type in Py_Finalize(). Currrently, these functions do nothing if Python is built in release mode. Clear static types: * AsyncGenHooksType: sys.set_asyncgen_hooks() * FlagsType: sys.flags * FloatInfoType: sys.float_info * Hash_InfoType: sys.hash_info * Int_InfoType: sys.int_info * ThreadInfoType: sys.thread_info * UnraisableHookArgsType: sys.unraisablehook * VersionInfoType: sys.version * WindowsVersionType: sys.getwindowsversion()
* bpo-46008: Move thread-related interpreter state into a sub-struct. (gh-29971)Eric Snow2021-12-071-1/+1
| | | | | This parallels _PyRuntimeState.interpreters. Doing this helps make it more clear what part of PyInterpreterState relates to its threads. https://bugs.python.org/issue46008
* bpo-44584: Deprecate PYTHONTHREADDEBUG env var (GH-27065)Victor Stinner2021-08-061-0/+19
| | | | | The threading debug (PYTHONTHREADDEBUG environment variable) is deprecated in Python 3.10 and will be removed in Python 3.12. This feature requires a debug build of Python.
* bpo-40268: Remove explicit pythread.h includes (#19529)Victor Stinner2020-04-151-2/+0
| | | | Remove explicit pythread.h includes: it is always included by Python.h.
* bpo-40268: Remove a few pycore_pystate.h includes (GH-19510)Victor Stinner2020-04-141-1/+1
|
* bpo-40268: Rename _PyInterpreterState_GET_UNSAFE() (GH-19509)Victor Stinner2020-04-141-1/+1
| | | | | | | Rename _PyInterpreterState_GET_UNSAFE() to _PyInterpreterState_GET() for consistency with _PyThreadState_GET() and to have a shorter name (help to fit into 80 columns). Add also "assert(tstate != NULL);" to the function.
* bpo-39947: Use _PyInterpreterState_GET_UNSAFE() (GH-18978)Victor Stinner2020-03-131-1/+1
| | | | | | | Replace _PyInterpreterState_Get() function call with _PyInterpreterState_GET_UNSAFE() macro which is more efficient but don't check if tstate or interp is NULL. _Py_GetConfigsAsDict() now uses _PyThreadState_GET().
* bpo-38096: Clean up the "struct sequence" / "named tuple" docs (GH-15895)Raymond Hettinger2019-09-111-1/+1
| | | | | | | | * bpo-38096: Clean up the "struct sequence" / "named tuple" docs * Fix remaining occurrences of "struct sequence" * Repair a user visible docstring
* bpo-35081: Rename internal headers (GH-10275)Victor Stinner2018-11-121-1/+1
| | | | | | | | | | | | | | Rename Include/internal/ headers: * pycore_hash.h -> pycore_pyhash.h * pycore_lifecycle.h -> pycore_pylifecycle.h * pycore_mem.h -> pycore_pymem.h * pycore_state.h -> pycore_pystate.h Add missing headers to Makefile.pre.in and PCbuild: * pycore_condvar.h. * pycore_hamt.h * pycore_pyhash.h
* bpo-35081: Add pycore_ prefix to internal header files (GH-10263)Victor Stinner2018-10-311-1/+1
| | | | | | | | | | | | | | | | | | | | * Rename Include/internal/ header files: * pyatomic.h -> pycore_atomic.h * ceval.h -> pycore_ceval.h * condvar.h -> pycore_condvar.h * context.h -> pycore_context.h * pygetopt.h -> pycore_getopt.h * gil.h -> pycore_gil.h * hamt.h -> pycore_hamt.h * hash.h -> pycore_hash.h * mem.h -> pycore_mem.h * pystate.h -> pycore_state.h * warnings.h -> pycore_warnings.h * PCbuild project, Makefile.pre.in, Modules/Setup: add the Include/internal/ directory to the search paths of header files. * Update includes. For example, replace #include "internal/mem.h" with #include "pycore_mem.h".
* bpo-34301: Add _PyInterpreterState_Get() helper function (GH-8592)Victor Stinner2018-08-031-1/+1
| | | | sys_setcheckinterval() now uses a local variable to parse arguments, before writing into interp->check_interval.
* bpo-32241: Add the const qualifire to declarations of umodifiable strings. ↵Serhiy Storchaka2017-12-121-1/+1
| | | | (#4748)
* bpo-25658: Implement PEP 539 for Thread Specific Storage (TSS) API (GH-1362)Masayuki Yamamoto2017-10-061-32/+28
| | | | | | | | | See PEP 539 for details. Highlights of changes: - Add Thread Specific Storage (TSS) API - Document the Thread Local Storage (TLS) API as deprecated - Update code that used TLS API to use TSS API
* bpo-30860: Consolidate stateful runtime globals. (#3397)Eric Snow2017-09-081-6/+2
| | | | | | | * group the (stateful) runtime globals into various topical structs * consolidate the topical structs under a single top-level _PyRuntimeState struct * add a check-c-globals.py script that helps identify runtime globals Other globals are excluded (see globals.txt and check-c-globals.py).
* Revert "bpo-30860: Consolidate stateful runtime globals." (#3379)Eric Snow2017-09-061-1/+6
| | | Windows buildbots started failing due to include-related errors.
* bpo-30860: Consolidate stateful runtime globals. (#2594)Eric Snow2017-09-061-6/+1
| | | | | | | | | * group the (stateful) runtime globals into various topical structs * consolidate the topical structs under a single top-level _PyRuntimeState struct * add a check-c-globals.py script that helps identify runtime globals Other globals are excluded (see globals.txt and check-c-globals.py).
* bpo-30832: Remove own implementation for thread-local storage (#2537)Masayuki Yamamoto2017-07-031-213/+8
| | | | | | | | | | | | | | | | * bpo-30832: Remove own implementation for thread-local storage CPython has provided the own implementation for thread-local storage (TLS) on Python/thread.c, it's used in the case which a platform has not supplied native TLS. However, currently all supported platforms (NT and pthreads) have provided native TLS and defined the Py_HAVE_NATIVE_TLS macro with unconditional in any case. * bpo-30832: replace NT with Windows * bpo-30832: change to directive chain * bpo-30832: remove comemnt which making no sense
* Doc nits for bpo-16500 (#1841)Antoine Pitrou2017-05-281-1/+1
| | | | | | * Doc nits for bpo-16500 * Fix more references
* bpo-30279: Remove unused Python/thread_foobar.h (#1473)Masayuki Yamamoto2017-05-051-6/+0
| | | | | | Python/thread_foobar.h is the template code that is threading adaptation for new platforms, also hasn't been used on actual platforms. Python/thread_*.h give concrete examples of adaptation instead of the template code.
* bpo-6532: Make the thread id an unsigned integer. (#781)Serhiy Storchaka2017-03-231-4/+4
| | | | | | | | | | | * bpo-6532: Make the thread id an unsigned integer. From C API side the type of results of PyThread_start_new_thread() and PyThread_get_thread_ident(), the id parameter of PyThreadState_SetAsyncExc(), and the thread_id field of PyThreadState changed from "long" to "unsigned long". * Restore a check in thread_get_ident().
* Issue #25523: Merge "a" to "an" fixes from 3.4 into 3.5Martin Panter2015-11-021-1/+1
|\
| * Issue #25523: Correct "a" article to "an" articleMartin Panter2015-11-021-1/+1
| | | | | | | | | | | | This changes the main documentation, doc strings, source code comments, and a couple error messages in the test suite. In some cases the word was removed or edited some other way to fix the grammar.
* | Removed duplicated words in in comments and docs.Serhiy Storchaka2014-12-011-1/+1
|\ \ | |/
| * Removed duplicated words in in comments and docs.Serhiy Storchaka2014-12-011-1/+1
| |
* | Issue #22156: Fix "comparison between signed and unsigned integers" compilerVictor Stinner2014-08-151-1/+1
|/ | | | warnings in the Python/ subdirectory.
* Issue #19787: PyThread_set_key_value() now always set the valueVictor Stinner2013-12-131-12/+8
| | | | | | | | | | In Python 3.3, PyThread_set_key_value() did nothing if the key already exists (if the current value is a non-NULL pointer). When _PyGILState_NoteThreadState() is called twice on the same thread with a different Python thread state, it still keeps the old Python thread state to keep the old behaviour. Replacing the Python thread state with the new state introduces new bugs: see issues #10915 and #15751.
* Backout changeset 46393019b650Victor Stinner2013-12-131-8/+12
| | | | test_capi is failing and the fix is not trivial, I prefer to revert
* Close #19787: PyThread_set_key_value() now always set the value. In Python 3.3,Victor Stinner2013-12-131-12/+8
| | | | | | | | the function did nothing if the key already exists (if the current value is a non-NULL pointer). _testcapi.run_in_subinterp() now correctly sets the new Python thread state of the current thread when a subinterpreter is created.
* Issue #18520: Add a new PyStructSequence_InitType2() function, same thanVictor Stinner2013-07-221-2/+4
| | | | | | | | PyStructSequence_InitType() except that it has a return value (0 on success, -1 on error). * PyStructSequence_InitType2() now raises MemoryError on memory allocation failure * Fix also some calls to PyDict_SetItemString(): handle error
* Issue #18203: Replace malloc() with PyMem_RawMalloc() at Python initializationVictor Stinner2013-07-071-4/+4
| | | | | | | * Replace malloc() with PyMem_RawMalloc() * Replace PyMem_Malloc() with PyMem_RawMalloc() where the GIL is not held. * _Py_char2wchar() now returns a buffer allocated by PyMem_RawMalloc(), instead of PyMem_Malloc()
* #16135: Removal of OS/2 support (I)Jesus Cea2012-10-041-4/+0
|
* Issue #11863: Remove support for legacy systems deprecated in Python 3.2Antoine Pitrou2011-07-081-43/+0
| | | | | (following PEP 11). These systems are systems using Mach C Threads, SunOS lightweight processes, GNU pth threads and IRIX threads.
* Issue #11223: Replace threading._info() by sys.thread_infoVictor Stinner2011-04-301-29/+54
|