summaryrefslogtreecommitdiffstats
path: root/Lib/threading.py
Commit message (Collapse)AuthorAgeFilesLines
* bpo-41149: Fix a bug in threading that causes fals-y threads callables to ↵BarneyStratford2021-02-021-1/+1
| | | | fail to start. (GH-21201)
* bpo-42350: Fix Thread._reset_internal_locks() (GH-23268)Victor Stinner2020-11-161-2/+6
| | | | | Fix the threading.Thread class at fork: do nothing if the thread is already stopped (ex: fork called at Python exit). Previously, an error was logged in the child process.
* bpo-42308: Add threading.__excepthook__ (GH-23218)Mario Corchero2020-11-121-0/+4
| | | | | Add threading.__excepthook__ to allow retrieving the original value of threading.excepthook in case it is set to a broken or a different value.
* bpo-42251: Add gettrace and getprofile to threading (GH-23125)Mario Corchero2020-11-041-1/+9
| | | This allows to retrieve the functions that were set in these two, which might differ from sys.gettrace and sys.getprofile within a thread.
* bpo-41833: threading.Thread now uses the target name (GH-22357)Victor Stinner2020-09-231-5/+15
|
* bpo-40234: Revert "bpo-37266: Daemon threads are now denied in ↵Victor Stinner2020-04-121-5/+0
| | | | | subinterpreters (GH-14049)" (GH-19456) This reverts commit 066e5b1a917ec2134e8997d2cadd815724314252.
* bpo-40089: Add _at_fork_reinit() method to locks (GH-19195)Victor Stinner2020-04-071-5/+15
| | | | | | | | | | | | | | | Add a private _at_fork_reinit() method to _thread.Lock, _thread.RLock, threading.RLock and threading.Condition classes: reinitialize the lock after fork in the child process; reset the lock to the unlocked state. Rename also the private _reset_internal_locks() method of threading.Event to _at_fork_reinit(). * Add _PyThread_at_fork_reinit() private function. It is excluded from the limited C API. * threading.Thread._reset_internal_locks() now calls _at_fork_reinit() on self._tstate_lock rather than creating a new Python lock object.
* bpo-39812: Remove daemon threads in concurrent.futures (GH-19149)Kyle Stanley2020-03-271-0/+29
| | | | | | Remove daemon threads from :mod:`concurrent.futures` by adding an internal `threading._register_atexit()`, which calls registered functions prior to joining all non-daemon threads. This allows for compatibility with subinterpreters, which don't support daemon threads.
* bpo-40089: Fix threading._after_fork() (GH-19191)Victor Stinner2020-03-271-1/+9
| | | | | If fork was not called by a thread spawned by threading.Thread, threading._after_fork() now creates a _MainThread instance for _main_thread, instead of a _DummyThread instance.
* bpo-15999: Clean up of handling boolean arguments. (GH-15610)Serhiy Storchaka2019-09-011-1/+1
| | | | | | * Use the 'p' format unit instead of manually called PyObject_IsTrue(). * Pass boolean value instead 0/1 integers to functions that needs boolean. * Convert some arguments to boolean only once.
* bpo-10978: Semaphores can release multiple threads at a time (GH-15588)Raymond Hettinger2019-08-291-9/+15
|
* Revert "bpo-37788: Fix a reference leak if a thread is not joined ↵Victor Stinner2019-08-191-10/+0
| | | | | (GH-15228)" (GH-15338) This reverts commit d3dcc92778807ae8f7ebe85178f36a29711cd478.
* bpo-37788: Fix a reference leak if a thread is not joined (GH-15228)Victor Stinner2019-08-191-0/+10
| | | | | Add threading.Thread.__del__() method to ensure that the thread state lock is removed from the _shutdown_locks list when a thread completes.
* bpo-37804: Remove the deprecated method threading.Thread.isAlive() (GH-15225)Dong-hee Na2019-08-121-10/+0
|
* Improve threading.daemon docstring (GH-14278)mbarkhau2019-06-221-2/+1
| | | Rephrase and clarify that "the entire Python program exits when only daemon threads are left". This matches the documentation at https://docs.python.org/3/library/threading.html#thread-objects.
* bpo-37266: Daemon threads are now denied in subinterpreters (GH-14049)Victor Stinner2019-06-141-0/+6
| | | | | | | | | | | | In a subinterpreter, spawning a daemon thread now raises an exception. Daemon threads were never supported in subinterpreters. Previously, the subinterpreter finalization crashed with a Pyton fatal error if a daemon thread was still running. * Add _thread._is_main_interpreter() * threading.Thread.start() now raises RuntimeError if the thread is a daemon thread and the method is called from a subinterpreter. * The _thread module now uses Argument Clinic for the new function. * Use textwrap.dedent() in test_threading.SubinterpThreadingTests
* tbpo-36402: Fix threading.Thread._stop() (GH-14047)Victor Stinner2019-06-131-1/+1
| | | Remove the _tstate_lock from _shutdown_locks, don't remove None.
* bpo-36402: Fix threading._shutdown() race condition (GH-13948)Victor Stinner2019-06-121-9/+40
| | | | | | | | | | | | | Fix a race condition at Python shutdown when waiting for threads. Wait until the Python thread state of all non-daemon threads get deleted (join all non-daemon threads), rather than just wait until Python threads complete. * Add threading._shutdown_locks: set of Thread._tstate_lock locks of non-daemon threads used by _shutdown() to wait until all Python thread states get deleted. See Thread._set_tstate_lock(). * Add also threading._shutdown_locks_lock to protect access to threading._shutdown_locks. * Add test_finalization_shutdown() test.
* bpo-1230540: Add threading.excepthook() (GH-13515)Victor Stinner2019-05-271-52/+103
| | | | | | | | | | | | | | | | | | | Add a new threading.excepthook() function which handles uncaught Thread.run() exception. It can be overridden to control how uncaught exceptions are handled. threading.ExceptHookArgs is not documented on purpose: it should not be used directly. * threading.excepthook() and threading.ExceptHookArgs. * Add _PyErr_Display(): similar to PyErr_Display(), but accept a 'file' parameter. * Add _thread._excepthook(): C implementation of the exception hook calling _PyErr_Display(). * Add _thread._ExceptHookArgs: structseq type. * Add threading._invoke_excepthook_wrapper() which handles the gory details to ensure that everything remains alive during Python shutdown. * Add unit tests.
* bpo-36084: Add native thread ID (TID) to threading.Thread (GH-13463)Jake Tesler2019-05-221-0/+30
| | | | Add native thread ID (TID) to threading.Thread objects (supported platforms: Windows, FreeBSD, Linux, macOS).
* Revert "bpo-36084: Add native thread ID to threading.Thread objects ↵Victor Stinner2019-05-211-21/+2
| | | | | (GH-11993)" (GH-13458) This reverts commit 4959c33d2555b89b494c678d99be81a65ee864b0.
* bpo-36084: Add native thread ID to threading.Thread objects (GH-11993)Jake Tesler2019-05-121-2/+21
|
* Fix typos and improve grammar in threading.Barrier docstrings (GH-12210)Carl Bordum Hansen2019-03-091-3/+3
|
* bpo-35283: Update the docstring of threading.Thread.join method (GH-11596)Dong-hee Na2019-01-181-1/+1
|
* bpo-35283: Add deprecation warning for Thread.isAlive (GH-11454)Dong-hee Na2019-01-171-1/+9
| | | Add a deprecated warning for the threading.Thread.isAlive() method.
* bpo-33556: Remove reference to thread module from docstring (GH-6963)Skip Montanaro2018-05-181-1/+1
|
* bpo-31516: current_thread() should not return a dummy thread at shutdown (#3673)Antoine Pitrou2017-10-021-2/+1
| | | | bpo-31516: current_thread() should not return a dummy thread at shutdown
* bpo-31370: Remove support for threads-less builds (#3385)Antoine Pitrou2017-09-071-32/+6
| | | | | | * Remove Setup.config * Always define WITH_THREAD for compatibility.
* bpo-18966: non-daemonic threads created by a multiprocessing.Process should ↵Antoine Pitrou2017-08-161-0/+3
| | | | | | | | be joined on exit (#3111) * bpo-18966: non-daemonic threads created by a multiprocessing.Process should be joined on exit * Add NEWS blurb
* bpo-16500: Don't use string constants for os.register_at_fork() behavior (#1834)Gregory P. Smith2017-05-291-2/+2
| | | | Instead use keyword only arguments to os.register_at_fork for each of the scenarios. Updates the documentation for clarity.
* bpo-16500: Use register_at_fork() in the threading module (#1843)Antoine Pitrou2017-05-281-4/+9
| | | | | | * bpo-16500: Use register_at_fork() in the threading module * Update comment at top of _after_fork()
* Doc nits for bpo-16500 (#1841)Antoine Pitrou2017-05-281-2/+2
| | | | | | * Doc nits for bpo-16500 * Fix more references
* bpo-6532: Make the thread id an unsigned integer. (#781)Serhiy Storchaka2017-03-231-2/+2
| | | | | | | | | | | * 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().
* bpo-29376: Fix assertion error in threading._DummyThread.is_alive() (GH-236)Xiang Zhang2017-02-271-0/+4
|
* Merge spelling and grammar fixes from 3.5Martin Panter2016-08-051-1/+1
|\
| * Fix spelling and grammar in documentation and code commentsMartin Panter2016-08-041-1/+1
| |
* | Issue #27076: Merge spelling from 3.5Martin Panter2016-05-261-1/+1
|\ \ | |/
| * Issue #27076: Doc, comment and tests spelling fixesMartin Panter2016-05-261-1/+1
| | | | | | | | Most fixes to Doc/ and Lib/ directories by Ville Skyttä.
* | Closes #26987: Merge with 3.5Zachary Ware2016-05-091-1/+1
|\ \ | |/
| * Issue #26987: Correct implementation to match commentZachary Ware2016-05-091-1/+1
| | | | | | | | | | This was inadvertently changed in 644b677c2ae5 to use self._stderr instead of _sys.stderr.
* | Issue #23883: Add missing APIs to __all__; patch by Jacek KołodziejMartin Panter2015-11-141-3/+5
|/
* merge 3.4 (#25362)Benjamin Peterson2015-10-111-12/+3
|\
| * use the with statement for locking the internal condition (closes #25362)Benjamin Peterson2015-10-111-12/+3
| | | | | | | | Patch by Nir Soffer.
* | merge 3.4 (#25319)Benjamin Peterson2015-10-061-1/+1
|\ \ | |/
| * reinitialize an Event's Condition with a regular lock (closes #25319)Benjamin Peterson2015-10-061-1/+1
| |
* | Merge: #11866: Eliminate race condition in the computation of names for new ↵R David Murray2014-10-041-5/+4
|\ \ | |/ | | | | threads.
| * #11866: Eliminate race condition in the computation of names for new threads.R David Murray2014-10-041-5/+4
| | | | | | | | Original patch by Peter Saveliev.
* | Issue #22423: Unhandled exception in thread no longer causes unhandledSerhiy Storchaka2014-09-211-8/+8
|\ \ | |/ | | | | AttributeError when sys.stderr is None.
| * Issue #22423: Unhandled exception in thread no longer causes unhandledSerhiy Storchaka2014-09-211-8/+8
| | | | | | | | AttributeError when sys.stderr is None.
* | Issue #22043: time.monotonic() is now always availableVictor Stinner2014-09-021-4/+1
| | | | | | | | | | threading.Lock.acquire(), threading.RLock.acquire() and socket operations now use a monotonic clock, instead of the system clock, when a timeout is used.