Skip to content

Conversation

@efimov-mikhail
Copy link
Member

@efimov-mikhailefimov-mikhail commented Oct 18, 2025

This PR just adds small test.
I've noticed that there's no such test because CI is green for this PR:
#140262, but it has such a flaw.

@bedevere-appbedevere-appbot added tests Tests in the Lib/test dir awaiting review labels Oct 18, 2025
@efimov-mikhailefimov-mikhail changed the title Test on GC collection disabled if threshold is zerogh-139951: Test on GC collection disabled if threshold is zeroOct 18, 2025
@efimov-mikhailefimov-mikhail added skip news needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels Oct 18, 2025
gc.enable()

# Ensure that setting *threshold0* to zero disables collection.
@gc_threshold(0, 0, 0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is better to set gc_threshold(0) to keep other values defaults.

Copy link
Contributor

@sergey-miryanovsergey-miryanov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Overall, I believe it is worth to add such test.

@markshannonmarkshannon self-requested a review October 20, 2025 10:42
Copy link
Member

@markshannonmarkshannon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks.

@markshannonmarkshannon merged commit 5d0abb6 into python:mainOct 20, 2025
51 checks passed
@miss-islington-app
Copy link

Thanks @efimov-mikhail for the PR, and @markshannon for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Oct 20, 2025
…ythonGH-140304) (cherry picked from commit 5d0abb6) Co-authored-by: Mikhail Efimov <efimov.mikhail@gmail.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Oct 20, 2025
…ythonGH-140304) (cherry picked from commit 5d0abb6) Co-authored-by: Mikhail Efimov <efimov.mikhail@gmail.com>
@bedevere-app
Copy link

GH-140362 is a backport of this pull request to the 3.14 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.14 bugs and security fixes label Oct 20, 2025
@bedevere-app
Copy link

GH-140363 is a backport of this pull request to the 3.13 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.13 bugs and security fixes label Oct 20, 2025
@bedevere-bot
Copy link

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot ARM64 macOS 3.x (tier-2) has failed when building commit 5d0abb6.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/#/builders/725/builds/12138) and take a look at the build logs.
  4. Check if the failure is related to this commit (5d0abb6) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/#/builders/725/builds/12138

Failed tests:

  • test_urllib2net

Failed subtests:

  • test_ftp_default_timeout - test.test_urllib2net.TimeoutTest.test_ftp_default_timeout
  • test_ftp_basic - test.test_urllib2net.TimeoutTest.test_ftp_basic

Summary of the results of the build (if available):

==

Click to see traceback logs
Traceback (most recent call last): File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/test/test_urllib2net.py", line 20, in _retry_thricereturn func(*args, **kwargs) File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/urllib/request.py", line 187, in urlopenreturn opener.open(url, data, timeout) ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^ File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/urllib/request.py", line 487, in open response =self._open(req, data) File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/urllib/request.py", line 504, in _open result =self._call_chain(self.handle_open, protocol, protocol +'_open', req) File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/urllib/request.py", line 464, in _call_chain result = func(*args) File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/urllib/request.py", line 1556, in ftp_openraise URLError(f"ftp error: {exp}") from exp urllib.error.URLError: <urlopen error ftp error: [Errno 60] Operation timed out> Traceback (most recent call last): File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/test/test_urllib2net.py", line 22, in _retry_thrice last_exc = e ^^^^^^^^ResourceWarning: unclosed <socket.socket fd=9, family=2, type=1, proto=6, laddr=('192.168.0.101', 55826), raddr=('68.183.26.59', 21)> ERROR Traceback (most recent call last): File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/test/test_urllib2net.py", line 330, in test_ftp_default_timeout u = _urlopen_with_retry(self.FTP_HOST) File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/test/test_urllib2net.py", line 28, in wrappedreturn _retry_thrice(func, exc, *args, **kwargs) File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/test/test_urllib2net.py", line 24, in _retry_thriceraise last_exc File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/test/test_urllib2net.py", line 20, in _retry_thricereturn func(*args, **kwargs) File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/urllib/request.py", line 187, in urlopenreturn opener.open(url, data, timeout) ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^ File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/urllib/request.py", line 487, in open response =self._open(req, data) File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/urllib/request.py", line 504, in _open result =self._call_chain(self.handle_open, protocol, protocol +'_open', req) File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/urllib/request.py", line 464, in _call_chain result = func(*args) File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/urllib/request.py", line 1556, in ftp_openraise URLError(f"ftp error: {exp}") from exp urllib.error.URLError: <urlopen error ftp error: [Errno 60] Operation timed out> Traceback (most recent call last): File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/test/test_urllib2net.py", line 22, in _retry_thrice last_exc = e ^^^^^^^^ResourceWarning: unclosed <socket.socket fd=7, family=2, type=1, proto=6, laddr=('192.168.0.101', 57890), raddr=('68.183.26.59', 21)> Warning -- Unraisable exception Exception ignored while finalizing socket <socket.socket fd=8, family=2, type=1, proto=6, laddr=('192.168.0.101', 57892), raddr=('68.183.26.59', 21)>: Traceback (most recent call last): File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/urllib/request.py", line 1546, in ftp_open fp, retrlen = fw.retrfile(file, type) ~~~~~~~~~~~^^^^^^^^^^^^ File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/urllib/request.py", line 1826, in retrfile conn, retrlen =self.ftp.ntransfercmd(cmd) ~~~~~~~~~~~~~~~~~~~~~^^^^^ File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/ftplib.py", line 354, in ntransfercmd conn = socket.create_connection((host, port), self.timeout, source_address=self.source_address) File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/socket.py", line 879, in create_connectionraise exceptions[0] File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/socket.py", line 864, in create_connection sock.connect(sa) ~~~~~~~~~~~~^^^^TimeoutError: [Errno 60] Operation timed out Traceback (most recent call last): File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/test/test_urllib2net.py", line 22, in _retry_thrice last_exc = e ^^^^^^^^ResourceWarning: unclosed <socket.socket fd=9, family=2, type=1, proto=6, laddr=('192.168.0.101', 57898), raddr=('68.183.26.59', 21)> ERROR Traceback (most recent call last): File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/test/test_urllib2net.py", line 22, in _retry_thrice last_exc = e ^^^^^^^^ResourceWarning: unclosed <socket.socket fd=8, family=2, type=1, proto=6, laddr=('192.168.0.101', 57892), raddr=('68.183.26.59', 21)> ERROR Traceback (most recent call last): File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/test/test_urllib2net.py", line 22, in _retry_thrice last_exc = e ^^^^^^^^ResourceWarning: unclosed <socket.socket fd=8, family=2, type=1, proto=6, laddr=('192.168.0.101', 57896), raddr=('68.183.26.59', 21)> Warning -- Unraisable exception Exception ignored while finalizing socket <socket.socket fd=9, family=2, type=1, proto=6, laddr=('192.168.0.101', 57898), raddr=('68.183.26.59', 21)>: Traceback (most recent call last): File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/urllib/request.py", line 1546, in ftp_open fp, retrlen = fw.retrfile(file, type) ~~~~~~~~~~~^^^^^^^^^^^^ File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/urllib/request.py", line 1826, in retrfile conn, retrlen =self.ftp.ntransfercmd(cmd) ~~~~~~~~~~~~~~~~~~~~~^^^^^ File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/ftplib.py", line 354, in ntransfercmd conn = socket.create_connection((host, port), self.timeout, source_address=self.source_address) File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/socket.py", line 879, in create_connectionraise exceptions[0] File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/socket.py", line 864, in create_connection sock.connect(sa) ~~~~~~~~~~~~^^^^TimeoutError: [Errno 60] Operation timed out Traceback (most recent call last): File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/test/libregrtest/single.py", line 165, in _load_run_test regrtest_runner(result, test_func, runtests) ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/test/libregrtest/single.py", line 118, in regrtest_runner test_result = test_func() File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/test/libregrtest/single.py", line 162, in test_funcreturn run_unittest(test_mod, runtests) File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/test/libregrtest/single.py", line 42, in run_unittestreturn _run_suite(tests) File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/test/libregrtest/single.py", line 105, in _run_suiteraise support.TestFailedWithDetails(err, errors, failures, stats=stats) Traceback (most recent call last): File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/urllib/request.py", line 1294, in do_open headers.update({k: v for k, v in req.headers.items() ~~~~~~~~~~~~~~~~~^^ResourceWarning: unclosed <socket.socket fd=6, family=2, type=1, proto=6, laddr=('192.168.0.101', 54862), raddr=('68.183.26.59', 21)> Warning -- Unraisable exception Exception ignored while finalizing socket <socket.socket fd=7, family=2, type=1, proto=6, laddr=('192.168.0.101', 57042), raddr=('68.183.26.59', 21)>: Traceback (most recent call last): File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/urllib/request.py", line 1294, in do_open headers.update({k: v for k, v in req.headers.items() ~~~~~~~~~~~~~~~~~^^ResourceWarning: unclosed <socket.socket fd=7, family=2, type=1, proto=6, laddr=('192.168.0.101', 57042), raddr=('68.183.26.59', 21)> k Traceback (most recent call last): File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/test/test_urllib2net.py", line 321, in test_ftp_basic u = _urlopen_with_retry(self.FTP_HOST) File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/test/test_urllib2net.py", line 28, in wrappedreturn _retry_thrice(func, exc, *args, **kwargs) File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/test/test_urllib2net.py", line 24, in _retry_thriceraise last_exc File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/test/test_urllib2net.py", line 20, in _retry_thricereturn func(*args, **kwargs) File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/urllib/request.py", line 187, in urlopenreturn opener.open(url, data, timeout) ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^ File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/urllib/request.py", line 487, in open response =self._open(req, data) File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/urllib/request.py", line 504, in _open result =self._call_chain(self.handle_open, protocol, protocol +'_open', req) File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/urllib/request.py", line 464, in _call_chain result = func(*args) File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/urllib/request.py", line 1556, in ftp_openraise URLError(f"ftp error: {exp}") from exp urllib.error.URLError: <urlopen error ftp error: [Errno 60] Operation timed out> Traceback (most recent call last): File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/urllib/request.py", line 1546, in ftp_open fp, retrlen = fw.retrfile(file, type) ~~~~~~~~~~~^^^^^^^^^^^^ File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/urllib/request.py", line 1826, in retrfile conn, retrlen =self.ftp.ntransfercmd(cmd) ~~~~~~~~~~~~~~~~~~~~~^^^^^ File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/ftplib.py", line 354, in ntransfercmd conn = socket.create_connection((host, port), self.timeout, source_address=self.source_address) File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/socket.py", line 879, in create_connectionraise exceptions[0] File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/socket.py", line 864, in create_connection sock.connect(sa) ~~~~~~~~~~~~^^^^TimeoutError: [Errno 60] Operation timed out Traceback (most recent call last): File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/test/test_urllib2net.py", line 22, in _retry_thrice last_exc = e ^^^^^^^^ResourceWarning: unclosed <socket.socket fd=7, family=2, type=1, proto=6, laddr=('192.168.0.101', 55476), raddr=('68.183.26.59', 21)> Warning -- Unraisable exception Exception ignored while finalizing socket <socket.socket fd=9, family=2, type=1, proto=6, laddr=('192.168.0.101', 55826), raddr=('68.183.26.59', 21)>: Traceback (most recent call last): File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/urllib/request.py", line 1546, in ftp_open fp, retrlen = fw.retrfile(file, type) ~~~~~~~~~~~^^^^^^^^^^^^ File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/urllib/request.py", line 1826, in retrfile conn, retrlen =self.ftp.ntransfercmd(cmd) ~~~~~~~~~~~~~~~~~~~~~^^^^^ File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/ftplib.py", line 354, in ntransfercmd conn = socket.create_connection((host, port), self.timeout, source_address=self.source_address) File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/socket.py", line 879, in create_connectionraise exceptions[0] File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/socket.py", line 864, in create_connection sock.connect(sa) ~~~~~~~~~~~~^^^^TimeoutError: [Errno 60] Operation timed out Traceback (most recent call last): File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/test/support/__init__.py", line 847, in gc_collect gc.collect() ~~~~~~~~~~^^ResourceWarning: unclosed <socket.socket fd=7, family=2, type=1, proto=6, laddr=('192.168.0.101', 57894), raddr=('68.183.26.59', 21)> Warning -- Unraisable exception Exception ignored while finalizing socket <socket.socket fd=8, family=2, type=1, proto=6, laddr=('192.168.0.101', 57900), raddr=('68.183.26.59', 21)>: Traceback (most recent call last): File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/test/libregrtest/single.py", line 165, in _load_run_test regrtest_runner(result, test_func, runtests) ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/test/libregrtest/single.py", line 118, in regrtest_runner test_result = test_func() File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/test/libregrtest/single.py", line 162, in test_funcreturn run_unittest(test_mod, runtests) File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/test/libregrtest/single.py", line 42, in run_unittestreturn _run_suite(tests) File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/test/libregrtest/single.py", line 105, in _run_suiteraise support.TestFailedWithDetails(err, errors, failures, stats=stats) Traceback (most recent call last): File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/test/test_urllib2net.py", line 22, in _retry_thrice last_exc = e ^^^^^^^^ResourceWarning: unclosed <socket.socket fd=7, family=2, type=1, proto=6, laddr=('192.168.0.101', 54613), raddr=('68.183.26.59', 21)> ERROR Traceback (most recent call last): File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/test/support/__init__.py", line 847, in gc_collect gc.collect() ~~~~~~~~~~^^ResourceWarning: unclosed <socket.socket fd=8, family=2, type=1, proto=6, laddr=('192.168.0.101', 57900), raddr=('68.183.26.59', 21)> Traceback (most recent call last): File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/test/test_urllib2net.py", line 22, in _retry_thrice last_exc = e ^^^^^^^^ResourceWarning: unclosed <socket.socket fd=6, family=2, type=1, proto=6, laddr=('192.168.0.101', 54268), raddr=('68.183.26.59', 21)> Warning -- Unraisable exception Exception ignored while finalizing socket <socket.socket fd=7, family=2, type=1, proto=6, laddr=('192.168.0.101', 54613), raddr=('68.183.26.59', 21)>: Traceback (most recent call last): File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/urllib/request.py", line 1546, in ftp_open fp, retrlen = fw.retrfile(file, type) ~~~~~~~~~~~^^^^^^^^^^^^ File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/urllib/request.py", line 1826, in retrfile conn, retrlen =self.ftp.ntransfercmd(cmd) ~~~~~~~~~~~~~~~~~~~~~^^^^^ File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/ftplib.py", line 354, in ntransfercmd conn = socket.create_connection((host, port), self.timeout, source_address=self.source_address) File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/socket.py", line 879, in create_connectionraise exceptions[0] File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/socket.py", line 864, in create_connection sock.connect(sa) ~~~~~~~~~~~~^^^^TimeoutError: [Errno 60] Operation timed out

JelleZijlstra pushed a commit that referenced this pull request Oct 21, 2025
…GH-140304) (#140363) gh-139951: Test on GC collection disabled if threshold is zero (GH-140304) (cherry picked from commit 5d0abb6) Co-authored-by: Mikhail Efimov <efimov.mikhail@gmail.com>
JelleZijlstra pushed a commit that referenced this pull request Oct 21, 2025
…GH-140304) (#140362) gh-139951: Test on GC collection disabled if threshold is zero (GH-140304) (cherry picked from commit 5d0abb6) Co-authored-by: Mikhail Efimov <efimov.mikhail@gmail.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip newstestsTests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@efimov-mikhail@bedevere-bot@sergey-miryanov@markshannon