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