issue_comments: 552729658
This data as json
html_url | issue_url | id | node_id | user | created_at | updated_at | author_association | body | reactions | issue | performed_via_github_app |
---|---|---|---|---|---|---|---|---|---|---|---|
https://github.com/simonw/datasette/issues/626#issuecomment-552729658 | https://api.github.com/repos/simonw/datasette/issues/626 | 552729658 | MDEyOklzc3VlQ29tbWVudDU1MjcyOTY1OA== | 9599 | 2019-11-12T04:31:13Z | 2019-11-12T04:31:13Z | OWNER | I'm giving up on this. I spent a bunch of time trying to get it to work and couldn't. My final attempt was inspired by https://github.com/encode/uvicorn/blob/e821fd1ff5653f989d500d41fa6ba070858f6843/tests/test_main.py#L10-L32 Here's the code that didn't work: ``` def test_asgi_app(app_client): from uvicorn.config import Config from uvicorn.main import Server class CustomServer(Server): def install_signal_handlers(self): pass def run_server(): asyncio.set_event_loop(asyncio.new_event_loop()) print("ooh new loop") config = Config(app=app_client.asgi_app, limit_max_requests=1, port=8642) config.load() server = CustomServer(config=config) server.run() with concurrent.futures.ThreadPoolExecutor(max_workers=1) as executor: future = executor.submit(run_server) future.result() while not server.started: print(server.__dict__) time.sleep(0.01) assert 200 == urllib.request.urlopen("http://localhost:8642/").status # This line will raise if there's an exception: future.result() ``` I got `RuntimeError: There is no current event loop in thread 'ThreadPoolExecutor-1_0'` | {"total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0} | 521282013 |