Commit Graph

87 Commits

Author SHA1 Message Date
Victor Stinner 1328fa31fe
gh-110393: Remove watchdog with hardcoded timeout (#110400)
test_builtin and test_socketserver no longer use signal.alarm() to
implement a watchdog with a hardcoded timeout (2 and 60 seconds).
Python test runner regrtest has two watchdogs: faulthandler and
timeout on running worker processes. Tests using short hardcoded
timeout can fail on slowest buildbots just because the timeout is too
short.
2023-10-05 15:02:48 +00:00
jb2170 d94b3a6f45
gh-103673: Add missing ForkingUnixStreamServer and ForkingUnixDatagramServer socketservers (#103674)
sockserver gains ForkingUnixStreamServer and ForkingUnixDatagramServer classes for consistency with all of the others. Ironically these existed but were buried in our test suite.

Addresses #103673 

<!-- gh-issue-number: gh-103673 -->
* Issue: gh-103673
<!-- /gh-issue-number -->

---------

Co-authored-by: Gregory P. Smith <greg@krypto.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2023-04-24 22:35:52 +00:00
Ankit Kumar Pandey 777bdff0ec
gh-103716: Add test support requires fork in simple_subprocess (gh-103717)
add requires fork as test case depends on this
2023-04-23 11:19:16 -06:00
Victor Stinner c5b750dc0b
gh-93852: Add test.support.create_unix_domain_name() (#93914)
test_asyncio, test_logging, test_socket and test_socketserver now
create AF_UNIX domains in the current directory to no longer fail
with OSError("AF_UNIX path too long") if the temporary directory (the
TMPDIR environment variable) is too long.

Modify the following tests to use create_unix_domain_name():

* test_asyncio
* test_logging
* test_socket
* test_socketserver

test_asyncio.utils: remove unused time import.
2022-06-17 13:16:51 +02:00
Christian Heimes cbc2c199a0
gh-84461: Skip network require tests on Emscripten (GH-92383) 2022-05-06 12:08:36 +02:00
Christian Heimes deeaac49e2
bpo-40280: Skip socket, fork, subprocess tests on Emscripten (GH-31986)
- 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).
2022-03-22 03:04:36 -07:00
Victor Stinner b136b1aac4
bpo-43843: libregrtest uses threading.excepthook (GH-25400)
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__.
2021-04-16 14:33:10 +02:00
Jason R. Coombs b5711c940f
bpo-37193: Remove thread objects which finished process its request (GH-23127)
This reverts commit aca67da4fe.
2020-12-31 20:19:30 +00:00
Jason R. Coombs aca67da4fe
Revert "bpo-37193: remove thread objects which finished process its request (GH-13893)" (GH-23107)
This reverts commit c415590212.
2020-11-02 16:48:56 +00:00
MARUYAMA Norihiro c415590212
bpo-37193: remove thread objects which finished process its request (GH-13893)
* bpo-37193: remove the thread which finished process request from threads list

* rename variable t to thread.

* don't remove thread from list if it is daemon.

* use lock to protect self._threads.

* use finally block in case of exception from shutdown_request().

* check "not thread.daemon" before lock to avoid holding the lock if it's unnecessary.

* fix the place of _threads_lock.

* separate code to remove a current thread into a function.

* check ValueError when removing thread.

* fix wrong code which all instance shared same lock.

* Extract thread management into a _Threads class to encapsulate atomic operations and separate concerns.

* Replace multiple references of 'block_on_close' with one, avoiding the possibility that 'block_on_close' could change during the course of processing requests. Now, there's exactly one _threads object with behavior fixed for the duration.

* Add docstrings to private classes.

* Add test to ensure that a ThreadingTCPServer can be closed without serving any requests.

* Use _NoThreads as the default value. Fixes AttributeError when server is closed without serving any requests.

* Add blurb

* Add test capturing failure.

Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
2020-11-01 18:51:04 -05:00
Hai Shi 79bb2c93f2
bpo-40275: Use new test.support helper submodules in tests (GH-21743) 2020-08-06 13:51:29 +02:00
Hai Shi e80697d687
bpo-40275: Adding threading_helper submodule in test.support (GH-20263) 2020-05-28 00:10:27 +02:00
Serhiy Storchaka 16994912c9
bpo-40275: Avoid importing socket in test.support (GH-19603)
* Move socket related functions from test.support to socket_helper.
* Import socket, nntplib and urllib.error lazily in transient_internet().
* Remove importing multiprocess.
2020-04-25 10:06:29 +03:00
Victor Stinner 278c1e159c
bpo-40094: Add test.support.wait_process() (GH-19254)
Moreover, the following tests now check the child process exit code:

* test_os.PtyTests
* test_mailbox.test_lock_conflict()
* test_tempfile.test_process_awareness()
* test_uuid.testIssue8621()
* multiprocessing resource tracker tests
2020-03-31 20:08:12 +02:00
Victor Stinner 0d63bacefd
bpo-38614: Use test.support.SHORT_TIMEOUT constant (GH-17566)
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.
2019-12-11 11:30:03 +01:00
Serhiy Storchaka 5b10b98247
bpo-22831: Use "with" to avoid possible fd leaks in tests (part 2). (GH-10929) 2019-03-05 10:06:26 +02:00
xdegaye 9001d1f438
bpo-29184: Skip test_socketserver tests on PermissionError raised by Android (GH-4387) 2017-11-18 18:10:53 +01:00
Antoine Pitrou a6a4dc816d bpo-31370: Remove support for threads-less builds (#3385)
* Remove Setup.config
* Always define WITH_THREAD for compatibility.
2017-09-07 18:56:24 +02:00
Victor Stinner aa8ec34ad5 bpo-31151: Add socketserver.ForkingMixIn.server_close() (#3057)
* Add socketserver.ForkingMixIn.server_close()

bpo-31151: socketserver.ForkingMixIn.server_close() now waits until
all child processes completed to prevent leaking zombie processes.

* Fix test on Windows which doesn't have ForkingMixIn
2017-08-10 15:28:16 +02:00
Serhiy Storchaka 5f1a5187f7 Use sequence repetition instead of bytes constructor with integer argument. 2016-09-11 14:41:02 +03:00
Martin Panter 34eeed4290 Issue #26721: Change StreamRequestHandler.wfile to BufferedIOBase 2016-06-29 10:12:22 +00:00
Gregory P. Smith ext:(%20%5BGoogle%20Inc.%5D) a945969d71 Issue25931: fix tests broken by the conditional define of socketserver.Forking* 2016-06-03 05:26:14 +00:00
Serhiy Storchaka e437a10d15 Issue #23277: Remove unused imports in tests. 2016-04-24 21:41:02 +03:00
Martin Panter 0cab9c1eba Issue #26404: Add context manager to socketserver, by Aviv Palivoda 2016-04-13 00:36:52 +00:00
Martin Panter 510addf63f Issue #5824: Merge socketserver tests from 3.5 2016-02-24 06:14:15 +00:00
Martin Panter 1827eff030 Issue #5824: Fix DatagramRequestHandler tests by binding the client socket 2016-02-24 05:12:59 +00:00
Martin Panter d9108d1253 Issue #23430: Stop socketserver from catching SystemExit etc from handlers
Also make handle_error() consistently output to stderr, and fix the
documentation.
2016-02-21 08:49:56 +00:00
Martin Panter 4bf427495f Issue #26309: Rewrite test in main thread and avoid race condition 2016-02-19 02:16:42 +00:00
Martin Panter c12fef9aa3 Issue #26309: Shut down socketserver request if verify_request() is false
Patch by Aviv Palivoda.
2016-02-18 10:43:55 +00:00
Robert Collins f7e3b5e153 Issue #23254: Document how to close the TCPServer listening socket.
Patch from Martin Panter.
2015-07-29 12:53:30 +12:00
Robert Collins 1ee9283254 Issue #23254: Document how to close the TCPServer listening socket.
Patch from Martin Panter.
2015-07-29 12:52:40 +12:00
Berker Peksag 50457403f2 Issue #23358: Add missing BaseServer entry to socketserver.__all__.
Patch by Martin Panter.
2015-02-03 11:55:32 +02:00
Berker Peksag 3265344a85 Issue #23358: Add missing BaseServer entry to socketserver.__all__.
Patch by Martin Panter.
2015-02-03 11:55:09 +02:00
Charles-François Natali acbf5235b8 Issue #22435: Fix a file descriptor leak when SocketServer bind fails. 2014-10-13 19:28:50 +01:00
Charles-François Natali 0f4f048fa5 Issue #22435: Fix a file descriptor leak when SocketServer bind fails. 2014-10-13 19:19:26 +01:00
Charles-François Natali 1d29cc5b6c Issue #21040: socketserver: Use the selectors module. 2014-03-24 22:25:39 +00:00
Serhiy Storchaka 43767638a9 Issue #18702: All skipped tests now reported as skipped. 2013-11-03 21:31:38 +02:00
Brett Cannon e4f41deccf Issue #17177: The imp module is pending deprecation.
To make sure there is no issue with code that is both Python 2 and 3
compatible, there are no plans to remove the module any sooner than
Python 4 (unless the community moves to Python 3 solidly before then).
2013-06-16 13:13:40 -04:00
Andrew Svetlov ad28c7f9da Issue #16706: get rid of os.error 2012-12-18 22:02:39 +02:00
Andrew Svetlov a191959849 Issue #16714: use 'raise' exceptions, don't 'throw'.
Patch by Serhiy Storchaka.
2012-12-18 21:27:16 +02:00
Andrew Svetlov 5b89840d9c Issue #16714: use 'raise' exceptions, don't 'throw'.
Patch by Serhiy Storchaka.
2012-12-18 21:26:36 +02:00
Andrew Svetlov 737fb89dd1 Issue #16714: use 'raise' exceptions, don't 'throw'.
Patch by Serhiy Storchaka.
2012-12-18 21:14:22 +02:00
Jesus Cea f1af705720 #16135: Removal of OS/2 support (Remove OS2 and OS/2 references) 2012-10-05 02:48:46 +02:00
Antoine Pitrou c0aa9eeb90 Fix the patch for issue #7978: select() raises select.error before 3.3, not OSError. 2012-04-09 01:37:19 +02:00
Antoine Pitrou f18d6f3f44 Fix flakiness in test_socketserver 2012-04-09 01:16:47 +02:00
Antoine Pitrou b0a9c66a49 Issue #7978: socketserver now restarts the select() call when EINTR is returned.
This avoids crashing the server loop when a signal is received.
Patch by Jerzy Kozera.
2012-04-09 00:47:24 +02:00
Florent Xicluna 12b66b5217 Closes #13140: Fix the daemon_threads attribute of ThreadingMixIn. 2011-11-04 10:16:28 +01:00
Victor Stinner 5702ae6f3f Issue #12250: test_socketserver uses a timeout of 60 seconds instead of 20
test_shutdown() may fail on very slow buildbots like FreeBSD 6.4 just because
of the arbitrary timeout.
2011-07-14 14:53:24 +02:00
Victor Stinner 109761ba07 test_sockserver: close servers when done 2011-01-03 14:30:39 +00:00
Ezio Melotti b3aedd4862 #9424: Replace deprecated assert* methods in the Python test suite. 2010-11-20 19:04:17 +00:00