{"html_url": "https://github.com/simonw/datasette/issues/1802#issuecomment-1237545794", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1802", "id": 1237545794, "node_id": "IC_kwDOBm6k_c5Jw3NC", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-09-06T00:31:31Z", "updated_at": "2022-09-06T00:31:31Z", "author_association": "OWNER", "body": "Well I'm not proud of it, but that did seem to do the trick!", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1362402998, "label": "Tests reliably failing on Python 3.7"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1802#issuecomment-1237542803", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1802", "id": 1237542803, "node_id": "IC_kwDOBm6k_c5Jw2eT", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-09-06T00:23:27Z", "updated_at": "2022-09-06T00:23:27Z", "author_association": "OWNER", "body": "Trying this fix:\r\n```diff\r\ndiff --git a/datasette/app.py b/datasette/app.py\r\nindex f2a6763a5..b17888a07 100644\r\n--- a/datasette/app.py\r\n+++ b/datasette/app.py\r\n@@ -231,7 +231,13 @@ def __init__(\r\n self.inspect_data = inspect_data\r\n self.immutables = set(immutables or [])\r\n self.databases = collections.OrderedDict()\r\n- self._refresh_schemas_lock = asyncio.Lock()\r\n+ try:\r\n+ self._refresh_schemas_lock = asyncio.Lock()\r\n+ except RuntimeError as rex:\r\n+ if \"There is no current event loop in thread\" in str(rex):\r\n+ loop = asyncio.new_event_loop()\r\n+ asyncio.set_event_loop(loop)\r\n+ self._refresh_schemas_lock = asyncio.Lock()\r\n self.crossdb = crossdb\r\n self.nolock = nolock\r\n if memory or crossdb or not self.files:\r\n```\r\nThis is mainly superstition at this point! I found that recipe on https://techoverflow.net/2020/10/01/how-to-fix-python-asyncio-runtimeerror-there-is-no-current-event-loop-in-thread/", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1362402998, "label": "Tests reliably failing on Python 3.7"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1802#issuecomment-1237542508", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1802", "id": 1237542508, "node_id": "IC_kwDOBm6k_c5Jw2Zs", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-09-06T00:22:37Z", "updated_at": "2022-09-06T00:22:37Z", "author_association": "OWNER", "body": "The code that I control that shows up in the trace is this:\r\n\r\nhttps://github.com/simonw/datasette/blob/fd1086c6867f3e3582b1eca456e4ea95f6cecf8b/datasette/app.py#L234", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1362402998, "label": "Tests reliably failing on Python 3.7"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1802#issuecomment-1237540231", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1802", "id": 1237540231, "node_id": "IC_kwDOBm6k_c5Jw12H", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-09-06T00:16:10Z", "updated_at": "2022-09-06T00:16:10Z", "author_association": "OWNER", "body": "Removing the `ensure_eventloop()` hack produced the exact same test failure: https://github.com/simonw/datasette/runs/8197570109?check_suite_focus=true", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1362402998, "label": "Tests reliably failing on Python 3.7"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1802#issuecomment-1237537205", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1802", "id": 1237537205, "node_id": "IC_kwDOBm6k_c5Jw1G1", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-09-06T00:08:03Z", "updated_at": "2022-09-06T00:08:46Z", "author_association": "OWNER", "body": "I'm suspicious that this hack here may be hurting me:\r\n\r\nhttps://github.com/simonw/datasette/blob/b91e17280c05bbb9cf97432081bdcea8665879f9/tests/test_cli.py#L25-L29\r\n\r\nI added that two years ago in https://github.com/simonw/datasette/commit/3159263f05ac4baf968929d59384d9223a539071", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1362402998, "label": "Tests reliably failing on Python 3.7"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1802#issuecomment-1237533471", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1802", "id": 1237533471, "node_id": "IC_kwDOBm6k_c5Jw0Mf", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-09-05T23:59:26Z", "updated_at": "2022-09-05T23:59:26Z", "author_association": "OWNER", "body": "https://docs.python.org/3/library/asyncio-task.html#asyncio.run notes that `asyncio.run()` was added in Python 3.7. I dropped support for 3.6 a while ago.\r\n\r\nhttps://stackoverflow.com/a/56446830/6083 suggests that switching to `asyncio.run()` has helped other people dealing with the `RuntimeError: There is no current event loop in thread` error in the past.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1362402998, "label": "Tests reliably failing on Python 3.7"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1802#issuecomment-1237532571", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1802", "id": 1237532571, "node_id": "IC_kwDOBm6k_c5Jwz-b", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-09-05T23:56:28Z", "updated_at": "2022-09-05T23:56:28Z", "author_association": "OWNER", "body": "That didn't help. This time it was 3.9 that failed first: https://github.com/simonw/datasette/runs/8197403744?check_suite_focus=true - same error though.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1362402998, "label": "Tests reliably failing on Python 3.7"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1802#issuecomment-1237530726", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1802", "id": 1237530726, "node_id": "IC_kwDOBm6k_c5Jwzhm", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-09-05T23:50:18Z", "updated_at": "2022-09-05T23:50:18Z", "author_association": "OWNER", "body": "Tried again, this time it failed with 3.8: https://github.com/simonw/datasette/runs/8197344556?check_suite_focus=true\r\n\r\nI'm going to try ditching the parallel test execution.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1362402998, "label": "Tests reliably failing on Python 3.7"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1802#issuecomment-1237527575", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1802", "id": 1237527575, "node_id": "IC_kwDOBm6k_c5JwywX", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-09-05T23:40:32Z", "updated_at": "2022-09-05T23:40:32Z", "author_association": "OWNER", "body": "That passed too:\r\n\r\n```\r\n========================================================= test session starts ==========================================================\r\nplatform linux -- Python 3.7.13, pytest-7.1.3, pluggy-1.0.0\r\nSQLite: 3.27.2\r\nrootdir: /mnt, configfile: pytest.ini\r\nplugins: asyncio-0.19.0, anyio-3.6.1, timeout-2.1.0, xdist-2.5.0, forked-1.4.0\r\nasyncio: mode=strict\r\ngw0 [1024] / gw1 [1024] / gw2 [1024] / gw3 [1024] / gw4 [1024] / gw5 [1024]\r\n................................................................................................................................ [ 12%]\r\n................................................................................................................................ [ 25%]\r\n...............................................................................................................ss............... [ 37%]\r\n................................................................................................................................ [ 50%]\r\n................................................................................................................................ [ 62%]\r\n.................................................s..........................s................................................... [ 75%]\r\n................................................................................................................................ [ 87%]\r\n................................................................................................................................ [100%]\r\n============================================= 1020 passed, 4 skipped in 294.43s (0:04:54) ==============================================\r\n========================================================= test session starts ==========================================================\r\nplatform linux -- Python 3.7.13, pytest-7.1.3, pluggy-1.0.0\r\nSQLite: 3.27.2\r\nrootdir: /mnt, configfile: pytest.ini\r\nplugins: asyncio-0.19.0, anyio-3.6.1, timeout-2.1.0, xdist-2.5.0, forked-1.4.0\r\nasyncio: mode=strict\r\ncollected 1054 items / 1024 deselected / 30 selected \r\n\r\ntests/test_package.py . [ 3%]\r\ntests/test_cli_serve_server.py ... [ 13%]\r\ntests/test_publish_cloudrun.py ...................... [ 86%]\r\ntests/test_publish_heroku.py .... [100%]\r\n\r\n================================================= 30 passed, 1024 deselected in 7.62s ==================================================\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1362402998, "label": "Tests reliably failing on Python 3.7"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1802#issuecomment-1237523178", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1802", "id": 1237523178, "node_id": "IC_kwDOBm6k_c5Jwxrq", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-09-05T23:28:11Z", "updated_at": "2022-09-05T23:28:11Z", "author_association": "OWNER", "body": "Trying this instead:\r\n```\r\ndocker run -it -v `pwd`:/mnt \\\r\n python:3.7-buster \\\r\n bash -c \"cd /mnt && pip install -e '.[test]' && pytest -n auto -m 'not serial' && pytest -m 'serial'\"\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1362402998, "label": "Tests reliably failing on Python 3.7"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1802#issuecomment-1237522793", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1802", "id": 1237522793, "node_id": "IC_kwDOBm6k_c5Jwxlp", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-09-05T23:27:08Z", "updated_at": "2022-09-05T23:27:08Z", "author_association": "OWNER", "body": "Here's how GitHub Actions runs them: https://github.com/simonw/datasette/blob/294ecd45f7801971dbeef383d0c5456ee95ab839/.github/workflows/test.yml#L27-L37", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1362402998, "label": "Tests reliably failing on Python 3.7"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1802#issuecomment-1237522547", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1802", "id": 1237522547, "node_id": "IC_kwDOBm6k_c5Jwxhz", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-09-05T23:26:19Z", "updated_at": "2022-09-05T23:26:19Z", "author_association": "OWNER", "body": "Annoyingly those tests pass just fine on my machine using that Docker recipe.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1362402998, "label": "Tests reliably failing on Python 3.7"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1802#issuecomment-1237522407", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1802", "id": 1237522407, "node_id": "IC_kwDOBm6k_c5Jwxfn", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-09-05T23:25:53Z", "updated_at": "2022-09-05T23:25:53Z", "author_association": "OWNER", "body": "Turned that into a TIL: https://til.simonwillison.net/docker/pytest-docker", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1362402998, "label": "Tests reliably failing on Python 3.7"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1802#issuecomment-1237519153", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1802", "id": 1237519153, "node_id": "IC_kwDOBm6k_c5Jwwsx", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-09-05T23:17:03Z", "updated_at": "2022-09-05T23:17:03Z", "author_association": "OWNER", "body": "Some previous issues where I've run Python in Docker:\r\n\r\n- https://github.com/simonw/datasette/issues/1344#issuecomment-849805778\r\n- https://github.com/simonw/datasette/issues/1647#issuecomment-1059819628\r\n\r\nFor this one I'm going to try this image: `python:3.7-buster` - from https://hub.docker.com/layers/library/python/3.7-buster/images/sha256-8a79c5ddabd9e3bceb7d274e515d85a3f5898bd983bb5761ec94186bc54ae968?context=explore\r\n\r\n```\r\ndocker run -it -v `pwd`:/mnt \\\r\n python:3.7-buster \\\r\n bash -c \"cd /mnt && pip install -e '.[test]' && pytest\"\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1362402998, "label": "Tests reliably failing on Python 3.7"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1802#issuecomment-1237405647", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1802", "id": 1237405647, "node_id": "IC_kwDOBm6k_c5JwU_P", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-09-05T19:21:41Z", "updated_at": "2022-09-05T19:21:41Z", "author_association": "OWNER", "body": "Step one: replicate this failure on my local machine. I'll probably use Docker for this.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1362402998, "label": "Tests reliably failing on Python 3.7"}, "performed_via_github_app": null}