summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_concurrent_futures
Commit message (Collapse)AuthorAgeFilesLines
* gh-109917: Fix test instability in test_concurrent_futures (#110306)elfstrom2023-10-031-1/+2
| | | | | | | | | | The test had an instability issue due to the ordering of the dummy queue operation and the real wakeup pipe operations. Both primitives are thread safe but not done atomically as a single update and may interleave arbitrarily. With the old order of operations this can lead to an incorrect state where the dummy queue is full but the wakeup pipe is empty. By swapping the order in clear() I think this can no longer happen in any possible operation interleaving (famous last words).
* gh-109649: Use os.process_cpu_count() (#110165)Victor Stinner2023-10-011-1/+1
| | | | | | | | | | | | | | | | | | | | Replace os.cpu_count() with os.process_cpu_count() in modules: * compileall * concurrent.futures * multiprocessing Replace os.cpu_count() with os.process_cpu_count() in programs: * _decimal deccheck.py test * freeze.py * multissltests.py * python -m test (regrtest) * wasm_build.py Other changes: * test.pythoninfo logs os.process_cpu_count(). * regrtest gets os.process_cpu_count() / os.cpu_count() in headers.
* gh-109047: concurrent.futures catches PythonFinalizationError (#109810)Victor Stinner2023-09-291-0/+29
| | | | | | | | | | | | | | | | | | | | | | | | | concurrent.futures: The *executor manager thread* now catches exceptions when adding an item to the *call queue*. During Python finalization, creating a new thread can now raise RuntimeError. Catch the exception and call terminate_broken() in this case. Add test_python_finalization_error() to test_concurrent_futures. concurrent.futures._ExecutorManagerThread changes: * terminate_broken() no longer calls shutdown_workers() since the call queue is no longer working anymore (read and write ends of the queue pipe are closed). * terminate_broken() now terminates child processes, not only wait until they complete. * _ExecutorManagerThread.terminate_broken() now holds shutdown_lock to prevent race conditons with ProcessPoolExecutor.submit(). multiprocessing.Queue changes: * Add _terminate_broken() method. * _start_thread() sets _thread to None on exception to prevent leaking "dangling threads" even if the thread was not started yet.
* gh-109594: Fix concurrent.futures test_timeout() (#110018)Victor Stinner2023-09-281-8/+9
| | | | | | | | Fix test_timeout() of test_concurrent_futures.test_wait. Remove the future which may or may not complete depending if it takes longer than the timeout ot not. Keep the second future which does not complete before wait(). Make also the test faster: 0.5 second instead of 6 seconds, so remove @support.requires_resource('walltime') decorator.
* gh-109565: Fix concurrent.futures test_future_times_out() (#109949)Victor Stinner2023-09-271-2/+5
| | | | as_completed() uses a timeout of 100 ms instead of 10 ms. Windows monotonic clock resolution is around 15.6 ms.
* gh-109832: concurrent.futures test_deadlock restores sys.stderr (#109887)Victor Stinner2023-09-261-0/+6
| | | | | test_error_at_task_unpickle() and test_error_during_result_unpickle_in_result_handler() now restore sys.stderr which is overriden by _raise_error_ignore_stderr().
* gh-105829: Fix concurrent.futures.ProcessPoolExecutor deadlock (#108513)elfstrom2023-09-221-1/+71
| | | | | | | | This fixes issue #105829, https://github.com/python/cpython/issues/105829 Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Antoine Pitrou <antoine@python.org> Co-authored-by: Chris Withers <chris@withers.org> Co-authored-by: Thomas Moreau <thomas.moreau.2010@gmail.com>
* gh-109702: Increase concurrent_futures deadlock timeout (#109703)Victor Stinner2023-09-221-1/+1
| | | | Replace SHORT_TIMEOUT with LONG_TIMEOUT in test_deadlock of test_concurrent_futures.
* gh-107219: Fix concurrent.futures terminate_broken() (#108974)Victor Stinner2023-09-061-0/+2
| | | | | | | | Fix a race condition in _ExecutorManagerThread.terminate_broken(): ignore the InvalidStateError on future.set_exception(). It can happen if the future is cancelled before the caller. Moreover, test_crash_big_data() now waits explicitly until the executor completes.
* gh-108416: Mark slow but not CPU bound test methods with ↵Serhiy Storchaka2023-09-052-0/+4
| | | | requires_resource('walltime') (GH-108480)
* gh-108416: Mark slow test methods with @requires_resource('cpu') (GH-108421)Serhiy Storchaka2023-09-021-0/+2
| | | | Only mark tests which spend significant system or user time, by itself or in subprocesses.
* gh-108388: Convert test_concurrent_futures to package (#108401)Victor Stinner2023-08-2411-0/+1844
Convert test_concurrent_futures to a package of sub-tests.