Skip to content

[Sandbox] Add failing too-many-files test - #219

Closed
florimondmanca wants to merge 4 commits into
masterfrom
fm/socket-eof-test-poc
Closed

[Sandbox] Add failing too-many-files test#219
florimondmanca wants to merge 4 commits into
masterfrom
fm/socket-eof-test-poc

Conversation

@florimondmanca

@florimondmancaflorimondmanca commented Oct 8, 2020

Copy link
Copy Markdown
Contributor

Sandbox PR to prove that something like #193 (comment) to #193 or #185 would work to prevent a regression for #182.

@florimondmanca

florimondmanca commented Oct 8, 2020

Copy link
Copy Markdown
ContributorAuthor

Yup 😄

https://github.com/encode/httpcore/pull/219/checks?check_run_id=1227636776#step:7:300

__________ test_detect_broken_connection_many_open_files[curio-anyio] __________backend = 'anyio', server = <tests.utils.Server object at 0x7f402178e550> @pytest.mark.anyio @pytest.mark.usefixtures("too_many_open_files_minus_one") @pytest.mark.skipif( platform.system() not in ("Linux", "Darwin"), reason="Not a problem on Windows", ) async def test_detect_broken_connection_many_open_files( backend: str, server: Server ) -> None: """ Regression test for: https://github.com/encode/httpcore/issues/182 """ async with httpcore.AsyncConnectionPool(backend=backend) as http: method = b"GET" url = (b"http", *server.netloc, b"/") headers = [server.host_header] # * First attempt will be successful because it will grab the last # available fd before what select() supports on the platform. # * Second attempt would have failed without a fix, due to a "filedescriptor # out of range in select()" exception. for _ in range(2):
> status_code, response_headers, stream, ext = await http.arequest( method, url, headers )tests/async_tests/test_interfaces.py:388: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ httpcore/_async/connection_pool.py:190: in arequest connection = await self._get_connection_from_pool(origin)httpcore/_async/connection_pool.py:230: in _get_connection_from_pool if connection.is_connection_dropped():httpcore/_async/connection.py:152: in is_connection_dropped return self.connection is not None and self.connection.is_connection_dropped()httpcore/_async/http11.py:205: in is_connection_dropped return self.socket.is_connection_dropped()_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <httpcore._backends.anyio.SocketStream object at 0x7f4020201c10> def is_connection_dropped(self) -> bool: raw_socket = self.stream.extra(SocketAttribute.raw_socket)
> rready, _wready, _xready = select.select([raw_socket], [], [], 0)E ValueError: filedescriptor out of range in select()httpcore/_backends/anyio.py:90: ValueError--------------------------- Captured stderr teardown ---------------------------Exception ignored in: <function _TemporaryFileCloser.__del__ at 0x7f4023676280>Traceback (most recent call last): File "/opt/hostedtoolcache/Python/3.8.6/x64/lib/python3.8/tempfile.py", line 440, in __del__ self.close() File "/opt/hostedtoolcache/Python/3.8.6/x64/lib/python3.8/tempfile.py", line 433, in close self.file.close()OSError: [Errno 9] Bad file descriptor__________ test_detect_broken_connection_many_open_files[trio-anyio] ___________backend = 'anyio', server = <tests.utils.Server object at 0x7f402178e550> @pytest.mark.anyio @pytest.mark.usefixtures("too_many_open_files_minus_one") @pytest.mark.skipif( platform.system() not in ("Linux", "Darwin"), reason="Not a problem on Windows", ) async def test_detect_broken_connection_many_open_files( backend: str, server: Server ) -> None: """ Regression test for: https://github.com/encode/httpcore/issues/182 """ async with httpcore.AsyncConnectionPool(backend=backend) as http: method = b"GET" url = (b"http", *server.netloc, b"/") headers = [server.host_header] # * First attempt will be successful because it will grab the last # available fd before what select() supports on the platform. # * Second attempt would have failed without a fix, due to a "filedescriptor # out of range in select()" exception. for _ in range(2):
> status_code, response_headers, stream, ext = await http.arequest( method, url, headers )tests/async_tests/test_interfaces.py:388: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ httpcore/_async/connection_pool.py:190: in arequest connection = await self._get_connection_from_pool(origin)httpcore/_async/connection_pool.py:230: in _get_connection_from_pool if connection.is_connection_dropped():httpcore/_async/connection.py:152: in is_connection_dropped return self.connection is not None and self.connection.is_connection_dropped()httpcore/_async/http11.py:205: in is_connection_dropped return self.socket.is_connection_dropped()_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <httpcore._backends.anyio.SocketStream object at 0x7f4020229a00> def is_connection_dropped(self) -> bool: raw_socket = self.stream.extra(SocketAttribute.raw_socket)
> rready, _wready, _xready = select.select([raw_socket], [], [], 0)E ValueError: filedescriptor out of range in select()httpcore/_backends/anyio.py:90: ValueError

@florimondmanca
florimondmanca deleted the fm/socket-eof-test-poc branch October 8, 2020 18:52
@florimondmanca
florimondmanca restored the fm/socket-eof-test-poc branch October 8, 2020 19:02
@florimondmanca

Copy link
Copy Markdown
ContributorAuthor

👍

https://github.com/encode/httpcore/pull/219/checks?check_run_id=1227750207#step:7:208

 def is_connection_dropped(self) -> bool: raw_socket = self.stream.extra(SocketAttribute.raw_socket)
> rready, _wready, _xready = select.select([raw_socket], [], [], 0)E ValueError: filedescriptor out of range in select()

@florimondmanca
florimondmanca deleted the fm/socket-eof-test-poc branch October 8, 2020 19:34
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@florimondmanca