summaryrefslogtreecommitdiffstats
path: root/Lib/test/lock_tests.py
Commit message (Collapse)AuthorAgeFilesLines
* [3.12] gh-109974: Fix threading lock_tests race conditions (#110057) (#110346)Victor Stinner2023-10-041-248/+373
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * gh-109974: Fix threading lock_tests race conditions (#110057) Fix race conditions in test_threading lock tests. Wait until a condition is met rather than using time.sleep() with a hardcoded number of seconds. * Replace sleeping loops with support.sleeping_retry() which raises an exception on timeout. * Add wait_threads_blocked(nthread) which computes a sleep depending on the number of threads. Remove _wait() function. * test_set_and_clear(): use a way longer Event.wait() timeout. * BarrierTests.test_repr(): wait until the 2 threads are waiting for the barrier. Use a way longer timeout for Barrier.wait() timeout. * test_thread_leak() no longer needs to count len(threading.enumerate()): Bunch uses threading_helper.wait_threads_exit() internally which does it in wait_for_finished(). * Add BaseLockTests.wait_phase() which implements a timeout. test_reacquire() and test_recursion_count() use wait_phase(). (cherry picked from commit 4e356ad183eeb567783f4a87fd092573da1e9252) * gh-109974: Fix more threading lock_tests race conditions (#110089) * Add context manager on Bunch class. * Bunch now catchs exceptions on executed functions and re-raise them at __exit__() as an ExceptionGroup. * Rewrite BarrierProxy.test_default_timeout(). Use a single thread. Only check that barrier.wait() blocks for at least default timeout seconds. * test_with(): inline _with() function. (cherry picked from commit 743e3572ee940a6cf88fd518e5f4a447905ba5eb)
* [3.12] gh-109593: Fix reentrancy issue in multiprocessing resource_tracker ↵Miss Islington (bot)2023-10-021-0/+36
| | | | | | | | | | | | (GH-109629) (#109898) gh-109593: Fix reentrancy issue in multiprocessing resource_tracker (GH-109629) --------- (cherry picked from commit 0eb98837b60bc58e57ad3e2b35c6b0e9ab634678) Co-authored-by: Antoine Pitrou <antoine@python.org> Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
* gh-84623: Remove unused imports in tests (#93772)Victor Stinner2022-06-131-1/+0
|
* bpo-40280: Skip socket, fork, subprocess tests on Emscripten (GH-31986)Christian Heimes2022-03-221-1/+1
| | | | | | | | | | | - Add requires_fork and requires_subprocess to more tests - Skip extension import tests if dlopen is not available - Don't assume that _testcapi is a shared extension - Skip a lot of socket tests that don't work on Emscripten - Skip mmap tests, mmap emulation is incomplete - venv does not work yet - Cannot get libc from executable The "entire" test suite is now passing on Emscripten with EMSDK from git head (91 suites are skipped).
* bpo-24391: Better reprs for threading objects. (GH-20534)Serhiy Storchaka2021-09-291-0/+36
| | | | Add reprs for Semaphore, BoundedSemaphore, Event, and Barrier.
* bpo-25130: Add calls of gc.collect() in tests to support PyPy (GH-28005)Serhiy Storchaka2021-08-291-0/+2
|
* bpo-40275: Adding threading_helper submodule in test.support (GH-20263)Hai Shi2020-05-271-4/+5
|
* bpo-40089: Add _at_fork_reinit() method to locks (GH-19195)Victor Stinner2020-04-071-2/+28
| | | | | | | | | | | | | | | 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-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.
* Fix typos mostly in comments, docs and test names (GH-15209)Min ho Kim2019-08-301-1/+1
|
* bpo-10978: Semaphores can release multiple threads at a time (GH-15588)Raymond Hettinger2019-08-291-0/+32
|
* bpo-35513: Replace time.time() with time.monotonic() in tests (GH-11182)Victor Stinner2018-12-171-13/+13
| | | | | | | Replace time.time() with time.monotonic() in tests to measure time delta. test_zipfile64: display progress every minute (60 secs) rather than every 5 minutes (5*60 seconds).
* bpo-32692: Fix test_threading.test_set_and_clear() (GH-8331)Victor Stinner2018-07-191-2/+3
| | | | | Increase the timeout: give timeout x 4 instead of timeout x 2 to threads to wait until the Event is set, but reduce the sleep from 500 ms to 250 ms. So the test should be more reliable and faster!
* bpo-32208: update threading.Semaphore docs and add unit test (#4709)Garrett Berg2017-12-071-2/+4
| | | | | | | | | | * fix issue32208: update threading.Semaphore docs and add unit test to validate correct behavior * add test for blocking * Update threading.rst * semaphore: remove documentation validation tests and move 'return value' test to BaseSemaphore
* bpo-31234: Add test.support.wait_threads_exit() (#3578)Victor Stinner2017-09-141-15/+17
| | | | Use _thread.count() to wait until threads exit. The new context manager prevents the "dangling thread" warning.
* bpo-31234: Try to fix lock_tests warning (#3557)Victor Stinner2017-09-131-0/+8
| | | | | | | Try to fix the "Warning -- threading_cleanup() failed to cleanup 1 threads" warning in test.lock_tests: wait a little bit longer to give time to the threads to complete. Warning seen on test_thread and test_importlib.
* bpo-30727: Fix a race condition in test_threading. (#2334)Serhiy Storchaka2017-06-231-5/+14
|
* Issue #25551: Test condition behavior instead of its internalsBerker Peksag2016-04-291-4/+5
|\ | | | | | | | | | | | | | | | | | | test_reset_internal_locks was looking at Event's _cond._lock. This makes it harder to change internals of the Condition object and makes the test fragile. The test was added by Nir Soffer in 6108d30dde21. Patch by Nir Soffer.
| * Issue #25551: Test condition behavior instead of its internalsBerker Peksag2016-04-291-4/+5
| | | | | | | | | | | | | | | | | | | | test_reset_internal_locks was looking at Event's _cond._lock. This makes it harder to change internals of the Condition object and makes the test fragile. The test was added by Nir Soffer in 6108d30dde21. Patch by Nir Soffer.
* | Issue #25298: Add lock and rlock weakref tests (Contributed by Nir Soffer).Raymond Hettinger2015-10-091-0/+12
|/
* merge 3.4 (#25319)Benjamin Peterson2015-10-061-0/+8
|\
| * reinitialize an Event's Condition with a regular lock (closes #25319)Benjamin Peterson2015-10-061-0/+8
| |
* | Make some tests more frienly to MemoryError.Serhiy Storchaka2015-03-281-2/+6
|\ \ | |/ | | | | Free memory, unlock hanging threads.
| * Make some tests more frienly to MemoryError.Serhiy Storchaka2015-03-281-2/+6
| | | | | | | | Free memory, unlock hanging threads.
* | Issue 21137: Better repr for threading.Lock()Raymond Hettinger2014-05-261-1/+7
|/
* Issue #8799: Reduce timing sensitivity of condition test by explicitlyKristjan Valur Jonsson2013-11-111-0/+15
| | | | delaying the main thread so that it doesn't race ahead of the workers.
* Add simple test for repr(lock)Christian Heimes2013-07-301-0/+5
|
* Issue #9260: A finer-grained import lock.Antoine Pitrou2012-05-171-1/+11
| | | | | Most of the import sequence now uses per-module locks rather than the global import lock, eliminating well-known issues with threads and imports.
* Issue #13502: threading: Fix a race condition in Event.wait() that made itCharles-François Natali2012-01-071-0/+16
|\ | | | | | | return False when the event was set and cleared right after.
| * Issue #13502: threading: Fix a race condition in Event.wait() that made itCharles-François Natali2012-01-071-0/+16
| | | | | | | | return False when the event was set and cleared right after.
* | Issue #11871: In test_threading.BarrierTests, bump the default barrier timeoutCharles-François Natali2011-07-271-3/+3
|\ \ | |/ | | | | to avoid timing-dependent failures.
| * Issue #11871: In test_threading.BarrierTests, bump the default barrier timeoutCharles-François Natali2011-07-271-3/+3
| | | | | | | | to avoid timing-dependent failures.
* | Close #12028: Make threading._get_ident() public, rename it toVictor Stinner2011-05-301-2/+2
| | | | | | | | | | threading.get_ident() and document it. This function was used by _thread.get_ident().
* | (Merge 3.2) Issue #12096: Fix a race condition inVictor Stinner2011-05-171-1/+1
|\ \ | |/ | | | | test_threading.test_waitfor(). Patch written by Charles-François Natali.
| * Issue #12096: Fix a race condition in test_threading.test_waitfor(). PatchVictor Stinner2011-05-171-1/+1
| | | | | | | | written by Charles-François Natali.
* | Issue #11915: threading.RLock()._release_save() raises a RuntimeError if theVictor Stinner2011-04-241-0/+2
|/ | | | lock was not acquired.
* Try to fix sporadic failure in test_thread/test_threadingAntoine Pitrou2011-04-041-1/+7
|\
| * Try to fix sporadic failure in test_thread/test_threadingAntoine Pitrou2011-04-041-1/+7
| |
| * Merged revisions 76138,76173 via svnmerge fromAntoine Pitrou2009-11-091-0/+546
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/branches/py3k ................ r76138 | antoine.pitrou | 2009-11-06 23:41:14 +0100 (ven., 06 nov. 2009) | 10 lines Merged revisions 76137 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r76137 | antoine.pitrou | 2009-11-06 23:34:35 +0100 (ven., 06 nov. 2009) | 4 lines Issue #7270: Add some dedicated unit tests for multi-thread synchronization primitives such as Lock, RLock, Condition, Event and Semaphore. ........ ................ r76173 | antoine.pitrou | 2009-11-09 17:08:16 +0100 (lun., 09 nov. 2009) | 11 lines Merged revisions 76172 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r76172 | antoine.pitrou | 2009-11-09 17:00:11 +0100 (lun., 09 nov. 2009) | 5 lines Issue #7282: Fix a memory leak when an RLock was used in a thread other than those started through `threading.Thread` (for example, using `thread.start_new_thread()`. ........ ................
* Issue #11618: Fix the timeout logic in threading.Lock.acquire() underAntoine Pitrou2011-03-301-0/+10
| | | | Windows.
* Issue 10260Kristján Valur Jónsson2010-11-181-0/+40
| | | | Adding the wait_for() method to threading.Condition
* Use laxer timeouts in barrier testsAntoine Pitrou2010-11-171-5/+5
|
* issue 10237Kristján Valur Jónsson2010-10-311-4/+7
| | | | After increasing the default timeout for the barrier, the unittest for the default timeout must be adjusted
* issue 10237Kristján Valur Jónsson2010-10-301-1/+1
| | | | Increase the default timout of the barries used in the barrier tests. This should solve unexpected timeouts on some machines.
* issue 8777Kristján Valur Jónsson2010-10-281-0/+190
| | | | Add threading.Barrier
* #10218: return timeout status from Condition.wait, mirroring other ↵Georg Brandl2010-10-281-13/+19
| | | | primitives' behavior.
* Issue #850728: Add a *timeout* parameter to the `acquire()` method ofAntoine Pitrou2010-04-171-0/+13
| | | | `threading.Semaphore` objects. Original patch by Torsten Landschoff.
* Issue #7316: the acquire() method of lock objects in the :mod:`threading`Antoine Pitrou2010-04-141-5/+39
| | | | | | module now takes an optional timeout argument in seconds. Timeout support relies on the system threading library, so as to avoid a semi-busy wait loop.
* Merged revisions 76172 via svnmerge fromAntoine Pitrou2009-11-091-0/+13
| | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r76172 | antoine.pitrou | 2009-11-09 17:00:11 +0100 (lun., 09 nov. 2009) | 5 lines Issue #7282: Fix a memory leak when an RLock was used in a thread other than those started through `threading.Thread` (for example, using `thread.start_new_thread()`. ........
* Merged revisions 76137 via svnmerge fromAntoine Pitrou2009-11-061-0/+533
svn+ssh://pythondev@svn.python.org/python/trunk ........ r76137 | antoine.pitrou | 2009-11-06 23:34:35 +0100 (ven., 06 nov. 2009) | 4 lines Issue #7270: Add some dedicated unit tests for multi-thread synchronization primitives such as Lock, RLock, Condition, Event and Semaphore. ........