{"html_url": "https://github.com/simonw/datasette/issues/1854#issuecomment-1291047214", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1854", "id": 1291047214, "node_id": "IC_kwDOBm6k_c5M89Eu", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-10-25T19:39:36Z", "updated_at": "2022-10-25T19:39:48Z", "author_association": "OWNER", "body": "This pattern should work (for the http server at least):\r\n```python\r\n # Loop until port 8041 serves traffic\r\n while True:\r\n try:\r\n httpx.get(\"http://localhost:8041/\")\r\n break\r\n except httpx.ConnectError:\r\n time.sleep(0.1)\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1422973111, "label": "Flaky test: test_serve_localhost_http"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1854#issuecomment-1291046958", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1854", "id": 1291046958, "node_id": "IC_kwDOBm6k_c5M89Au", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-10-25T19:39:22Z", "updated_at": "2022-10-25T19:39:22Z", "author_association": "OWNER", "body": "Here's the code that starts those various servers: https://github.com/simonw/datasette/blob/613ad05c095f92653221db267ef53d54d00cdfbb/tests/conftest.py#L104-L177\r\n\r\nI don't like those `time.sleep(1.5)` lines much - I'm going to try polling for readiness instead.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1422973111, "label": "Flaky test: test_serve_localhost_http"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1854#issuecomment-1291045997", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1854", "id": 1291045997, "node_id": "IC_kwDOBm6k_c5M88xt", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-10-25T19:38:28Z", "updated_at": "2022-10-25T19:38:28Z", "author_association": "OWNER", "body": "Also:\r\n```\r\n @pytest.mark.serial\r\n @pytest.mark.skipif(\r\n not hasattr(socket, \"AF_UNIX\"), reason=\"Requires socket.AF_UNIX support\"\r\n )\r\n def test_serve_unix_domain_socket(ds_unix_domain_socket_server):\r\n _, uds = ds_unix_domain_socket_server\r\n transport = httpx.HTTPTransport(uds=uds)\r\n client = httpx.Client(transport=transport)\r\n> response = client.get(\"http://localhost/_memory.json\")\r\n\r\n/home/runner/work/datasette/datasette/tests/test_cli_serve_server.py:35: \r\n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \r\n/opt/hostedtoolcache/Python/3.10.8/x64/lib/python3.10/site-packages/httpx/_client.py:1039: in get\r\n return self.request(\r\n/opt/hostedtoolcache/Python/3.10.8/x64/lib/python3.10/site-packages/httpx/_client.py:815: in request\r\n return self.send(request, auth=auth, follow_redirects=follow_redirects)\r\n/opt/hostedtoolcache/Python/3.10.8/x64/lib/python3.10/site-packages/httpx/_client.py:902: in send\r\n response = self._send_handling_auth(\r\n/opt/hostedtoolcache/Python/3.10.8/x64/lib/python3.10/site-packages/httpx/_client.py:930: in _send_handling_auth\r\n response = self._send_handling_redirects(\r\n/opt/hostedtoolcache/Python/3.10.8/x64/lib/python3.10/site-packages/httpx/_client.py:967: in _send_handling_redirects\r\n response = self._send_single_request(request)\r\n/opt/hostedtoolcache/Python/3.10.8/x64/lib/python3.10/site-packages/httpx/_client.py:1003: in _send_single_request\r\n response = transport.handle_request(request)\r\n/opt/hostedtoolcache/Python/3.10.8/x64/lib/python3.10/site-packages/httpx/_transports/default.py:217: in handle_request\r\n with map_httpcore_exceptions():\r\n/opt/hostedtoolcache/Python/3.10.8/x64/lib/python3.10/contextlib.py:153: in __exit__\r\n self.gen.throw(typ, value, traceback)\r\n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \r\n\r\n @contextlib.contextmanager\r\n def map_httpcore_exceptions() -> typing.Iterator[None]:\r\n try:\r\n yield\r\n except Exception as exc: # noqa: PIE-786\r\n mapped_exc = None\r\n \r\n for from_exc, to_exc in HTTPCORE_EXC_MAP.items():\r\n if not isinstance(exc, from_exc):\r\n continue\r\n # We want to map to the most specific exception we can find.\r\n # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to\r\n # `httpx.ReadTimeout`, not just `httpx.TimeoutException`.\r\n if mapped_exc is None or issubclass(to_exc, mapped_exc):\r\n mapped_exc = to_exc\r\n \r\n if mapped_exc is None: # pragma: nocover\r\n raise\r\n \r\n message = str(exc)\r\n> raise mapped_exc(message) from exc\r\nE httpx.ConnectError: [Errno 2] No such file or directory\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1422973111, "label": "Flaky test: test_serve_localhost_http"}, "performed_via_github_app": null}