summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_threading.py
Commit message (Collapse)AuthorAgeFilesLines
* bpo-43988: Use check disallow instantiation helper (GH-26392)Erlend Egeberg Aasland2021-05-271-2/+1
|
* bpo-25872: Add unit tests for linecache and threading (GH-25913)uniocto2021-05-181-1/+18
|
* bpo-37788: Fix reference leak when Thread is never joined (GH-26103)Antoine Pitrou2021-05-141-0/+7
| | | When a Thread is not joined after it has stopped, its lock may remain in the _shutdown_locks set until interpreter shutdown. If many threads are created this way, the _shutdown_locks set could therefore grow endlessly. To avoid such a situation, purge expired locks each time a new one is added or removed.
* bpo-43916: Apply Py_TPFLAGS_DISALLOW_INSTANTIATION to selected types (GH-25748)Erlend Egeberg Aasland2021-04-301-0/+7
| | | | | | | | | | | | | | | | | | | | | Apply Py_TPFLAGS_DISALLOW_INSTANTIATION to the following types: * _dbm.dbm * _gdbm.gdbm * _multibytecodec.MultibyteCodec * _sre..SRE_Scanner * _thread._localdummy * _thread.lock * _winapi.Overlapped * array.arrayiterator * functools.KeyWrapper * functools._lru_list_elem * pyexpat.xmlparser * re.Match * re.Pattern * unicodedata.UCD * zlib.Compress * zlib.Decompress
* bpo-43843: libregrtest uses threading.excepthook (GH-25400)Victor Stinner2021-04-161-0/+13
| | | | | | | | | test.libregrtest now marks a test as ENV_CHANGED (altered the execution environment) if a thread raises an exception but does not catch it. It sets a hook on threading.excepthook. Use --fail-env-changed option to mark the test as failed. libregrtest regrtest_unraisable_hook() explicitly flushs sys.stdout, sys.stderr and sys.__stderr__.
* bpo-43723: Deprecate camelCase aliases from threading (GH-25174)Jelle Zijlstra2021-04-121-8/+27
| | | | | | The snake_case names have existed since Python 2.6, so there is no reason to keep the old camelCase names around. One similar method, threading.Thread.isAlive, was already removed in Python 3.9 (bpo-37804).
* bpo-43356: Allow passing a signal number to interrupt_main() (GH-24755)Antoine Pitrou2021-03-111-10/+33
| | | | Also introduce a new C API ``PyErr_SetInterruptEx(int signum)``.
* bpo-41149: Fix a bug in threading that causes fals-y threads callables to ↵BarneyStratford2021-02-021-0/+20
| | | | fail to start. (GH-21201)
* bpo-42639: atexit now logs callbacks exceptions (GH-23771)Victor Stinner2020-12-141-1/+0
| | | | | | | | | | | At Python exit, if a callback registered with atexit.register() fails, its exception is now logged. Previously, only some exceptions were logged, and the last exception was always silently ignored. Add _PyAtExit_Call() function and remove PyInterpreterState.atexit_func member. call_py_exitfuncs() now calls directly _PyAtExit_Call(). The atexit module must now always be built as a built-in module.
* bpo-42350: Fix Thread._reset_internal_locks() (GH-23268)Victor Stinner2020-11-161-0/+29
| | | | | 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/+21
| | | | | 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-0/+21
| | | 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-3/+31
|
* bpo-41521: Rename blacklist parameter to not_exported (GH-21824)Victor Stinner2020-08-171-2/+2
| | | | Rename "blacklist" parameter of test.support.check__all__() to "not_exported".
* bpo-40275: Use new test.support helper submodules in tests (GH-21449)Hai Shi2020-08-031-1/+2
|
* bpo-40275: Adding threading_helper submodule in test.support (GH-20263)Hai Shi2020-05-271-4/+5
|
* bpo-40234: Revert "bpo-37266: Daemon threads are now denied in ↵Victor Stinner2020-04-121-23/+19
| | | | | subinterpreters (GH-14049)" (GH-19456) This reverts commit 066e5b1a917ec2134e8997d2cadd815724314252.
* bpo-40094: Enhance threading tests (GH-19260)Victor Stinner2020-03-311-13/+20
| | | | | | | * Rewrite test_thread.test_forkinthread() to use support.wait_process() and wait for the child process in the main thread, not in the spawned thread. * test_threading now uses support.wait_process() and checks the child process exit code to detect crashes.
* bpo-39812: Remove daemon threads in concurrent.futures (GH-19149)Kyle Stanley2020-03-271-0/+50
| | | | | | 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-20526: Fix PyThreadState_Clear(): don't decref frame (GH-19120)Victor Stinner2020-03-241-28/+0
| | | | | | | | PyThreadState.frame is a borrowed reference, not a strong reference: PyThreadState_Clear() must not call Py_CLEAR(tstate->frame). Remove test_threading.test_warnings_at_exit(): we cannot warranty that the Python thread state of daemon threads is cleared in a reliable way during Python shutdown.
* bpo-19466: Py_Finalize() clears daemon threads earlier (GH-18848)Victor Stinner2020-03-091-0/+45
| | | | | | | | Clear the frames of daemon threads earlier during the Python shutdown to call objects destructors. So "unclosed file" resource warnings are now emitted for daemon threads in a more reliable way. Cleanup _PyThreadState_DeleteExcept() code: rename "garbage" to "list".
* bpo-39489: Remove COUNT_ALLOCS special build (GH-18259)Victor Stinner2020-02-031-4/+1
| | | | | | | | | | | Remove: * COUNT_ALLOCS macro * sys.getcounts() function * SHOW_ALLOC_COUNT code in listobject.c * SHOW_TRACK_COUNT code in tupleobject.c * PyConfig.show_alloc_count field * -X showalloccount command line option * @test.support.requires_type_collecting decorator
* bpo-38614: Use test.support.SHORT_TIMEOUT constant (GH-17566)Victor Stinner2019-12-111-2/+2
| | | | | | | | | | | | | | | Replace hardcoded timeout constants in tests with SHORT_TIMEOUT of test.support, so it's easier to ajdust this timeout for all tests at once. SHORT_TIMEOUT is 30 seconds by default, but it can be longer depending on --timeout command line option. The change makes almost all timeouts longer, except test_reap_children() of test_support which is made 2x shorter: SHORT_TIMEOUT should be enough. If this test starts to fail, LONG_TIMEOUT should be used instead. Uniformize also "from test import support" import in some test files.
* Revert "bpo-37788: Fix a reference leak if a thread is not joined ↵Victor Stinner2019-08-191-8/+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/+8
| | | | | 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-2/+0
|
* bpo-18049: Sync thread stack size to main thread size on macOS (GH-14748)Ronald Oussoren2019-08-011-2/+0
| | | | | | This changeset increases the default size of the stack for threads on macOS to the size of the stack of the main thread and reenables the relevant recursion test.
* Fix typos in comments, docs and test names (#15018)Min ho Kim2019-07-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | * Fix typos in comments, docs and test names * Update test_pyparse.py account for change in string length * Apply suggestion: splitable -> splittable Co-Authored-By: Terry Jan Reedy <tjreedy@udel.edu> * Apply suggestion: splitable -> splittable Co-Authored-By: Terry Jan Reedy <tjreedy@udel.edu> * Apply suggestion: Dealloccte -> Deallocate Co-Authored-By: Terry Jan Reedy <tjreedy@udel.edu> * Update posixmodule checksum. * Reverse idlelib changes.
* bpo-37266: Daemon threads are now denied in subinterpreters (GH-14049)Victor Stinner2019-06-141-29/+37
| | | | | | | | | | | | 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-0/+24
| | | Remove the _tstate_lock from _shutdown_locks, don't remove None.
* bpo-36402: Fix threading._shutdown() race condition (GH-13948)Victor Stinner2019-06-121-3/+52
| | | | | | | | | | | | | 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-36829: test_threading: Fix a ref cycle (GH-13752)Victor Stinner2019-06-021-1/+5
|
* bpo-1230540: Add threading.excepthook() (GH-13515)Victor Stinner2019-05-271-0/+92
| | | | | | | | | | | | | | | | | | | 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-23395: Fix PyErr_SetInterrupt if the SIGINT signal is ignored or not ↵Matěj Cepl2019-05-231-0/+35
| | | | | handled (GH-7778) ``_thread.interrupt_main()`` now avoids setting the Python error status if the ``SIGINT`` signal is ignored or not handled by Python.
* bpo-36084: Add native thread ID (TID) to threading.Thread (GH-13463)Jake Tesler2019-05-221-0/+5
| | | | 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-4/+0
| | | | | (GH-11993)" (GH-13458) This reverts commit 4959c33d2555b89b494c678d99be81a65ee864b0.
* bpo-36084: Add native thread ID to threading.Thread objects (GH-11993)Jake Tesler2019-05-121-0/+4
|
* bpo-22831: Use "with" to avoid possible fd leaks in tests (part 2). (GH-10929)Serhiy Storchaka2019-03-051-7/+5
|
* bpo-35283: Add deprecation warning for Thread.isAlive (GH-11454)Dong-hee Na2019-01-171-1/+2
| | | Add a deprecated warning for the threading.Thread.isAlive() method.
* bpo-31516: Skip test_main_thread_during_shutdown() with COUNT_ALLOCS builds. ↵Zackery Spytz2018-10-121-0/+1
| | | | (GH-8052)
* bpo-32593: Drop FreeBSD 9 and older support (#5232)Victor Stinner2018-01-221-2/+1
| | | Drop support of FreeBSD 9 and older.
* Replace KB unit with KiB (#4293)Victor Stinner2017-11-081-4/+4
| | | | | | | | | | | kB (*kilo* byte) unit means 1000 bytes, whereas KiB ("kibibyte") means 1024 bytes. KB was misused: replace kB or KB with KiB when appropriate. Same change for MB and GB which become MiB and GiB. Change the output of Tools/iobench/iobench.py. Round also the size of the documentation from 5.5 MB to 5 MiB.
* Fix miscellaneous typos (#4275)luzpaz2017-11-051-1/+1
|
* bpo-31516: current_thread() should not return a dummy thread at shutdown (#3673)Antoine Pitrou2017-10-021-0/+29
| | | | bpo-31516: current_thread() should not return a dummy thread at shutdown
* bpo-31234: Join timers in test_threading (#3598)Victor Stinner2017-09-151-0/+2
| | | | Call the .join() method of threading.Timer timers to prevent the "threading_cleanup() failed to cleanup 1 threads" warning.
* bpo-31234: Add test.support.wait_threads_exit() (#3578)Victor Stinner2017-09-141-6/+8
| | | | Use _thread.count() to wait until threads exit. The new context manager prevents the "dangling thread" warning.
* bpo-31234: Join threads in test_threading (#3579)Victor Stinner2017-09-141-0/+4
| | | Call thread.join() to prevent the "dangling thread" warning.
* bpo-31370: Remove support for threads-less builds (#3385)Antoine Pitrou2017-09-071-2/+2
| | | | | | * Remove Setup.config * Always define WITH_THREAD for compatibility.
* bpo-31234: test_threading: fix ref cycle (#3150)Victor Stinner2017-08-181-0/+2
| | | | test_bare_raise_in_brand_new_thread() now explicitly breaks a reference cycle to not leak a dangling thread.
* bpo-30387: Fix warning in test_threading (#1634)Victor Stinner2017-05-171-3/+5
| | | | | | | | | test_is_alive_after_fork() now joins directly the thread to avoid the following warning added by bpo-30357: Warning -- threading_cleanup() failed to cleanup 0 threads after 2 sec (count: 0, dangling: 21) Use also a different exit code to catch generic exit code 1.