mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Revert "asyncio_run helper to deal with a 3.10 warning, refs #1482"
This reverts commit 98dcabccbb.
This commit is contained in:
parent
875117c343
commit
0d5cc20aef
2 changed files with 8 additions and 14 deletions
|
|
@ -14,7 +14,6 @@ from runpy import run_module
|
||||||
import webbrowser
|
import webbrowser
|
||||||
from .app import Datasette, DEFAULT_SETTINGS, SETTINGS, SQLITE_LIMIT_ATTACHED, pm
|
from .app import Datasette, DEFAULT_SETTINGS, SETTINGS, SQLITE_LIMIT_ATTACHED, pm
|
||||||
from .utils import (
|
from .utils import (
|
||||||
asyncio_run,
|
|
||||||
StartupError,
|
StartupError,
|
||||||
check_connection,
|
check_connection,
|
||||||
find_spatialite,
|
find_spatialite,
|
||||||
|
|
@ -137,7 +136,9 @@ def cli():
|
||||||
@click.option("--inspect-file", default="-")
|
@click.option("--inspect-file", default="-")
|
||||||
@sqlite_extensions
|
@sqlite_extensions
|
||||||
def inspect(files, inspect_file, sqlite_extensions):
|
def inspect(files, inspect_file, sqlite_extensions):
|
||||||
inspect_data = asyncio_run(inspect_(files, sqlite_extensions))
|
app = Datasette([], immutables=files, sqlite_extensions=sqlite_extensions)
|
||||||
|
loop = asyncio.get_event_loop()
|
||||||
|
inspect_data = loop.run_until_complete(inspect_(files, sqlite_extensions))
|
||||||
if inspect_file == "-":
|
if inspect_file == "-":
|
||||||
sys.stdout.write(json.dumps(inspect_data, indent=2))
|
sys.stdout.write(json.dumps(inspect_data, indent=2))
|
||||||
else:
|
else:
|
||||||
|
|
@ -554,10 +555,10 @@ def serve(
|
||||||
return ds
|
return ds
|
||||||
|
|
||||||
# Run the "startup" plugin hooks
|
# Run the "startup" plugin hooks
|
||||||
asyncio_run(ds.invoke_startup())
|
asyncio.get_event_loop().run_until_complete(ds.invoke_startup())
|
||||||
|
|
||||||
# Run async soundness checks - but only if we're not under pytest
|
# Run async soundness checks - but only if we're not under pytest
|
||||||
asyncio_run(check_databases(ds))
|
asyncio.get_event_loop().run_until_complete(check_databases(ds))
|
||||||
|
|
||||||
if get:
|
if get:
|
||||||
client = TestClient(ds)
|
client = TestClient(ds)
|
||||||
|
|
@ -577,7 +578,9 @@ def serve(
|
||||||
if open_browser:
|
if open_browser:
|
||||||
if url is None:
|
if url is None:
|
||||||
# Figure out most convenient URL - to table, database or homepage
|
# Figure out most convenient URL - to table, database or homepage
|
||||||
path = asyncio_run(initial_path_for_datasette(ds))
|
path = asyncio.get_event_loop().run_until_complete(
|
||||||
|
initial_path_for_datasette(ds)
|
||||||
|
)
|
||||||
url = f"http://{host}:{port}{path}"
|
url = f"http://{host}:{port}{path}"
|
||||||
webbrowser.open(url)
|
webbrowser.open(url)
|
||||||
uvicorn_kwargs = dict(
|
uvicorn_kwargs = dict(
|
||||||
|
|
|
||||||
|
|
@ -1089,12 +1089,3 @@ async def derive_named_parameters(db, sql):
|
||||||
return [row["p4"].lstrip(":") for row in results if row["opcode"] == "Variable"]
|
return [row["p4"].lstrip(":") for row in results if row["opcode"] == "Variable"]
|
||||||
except sqlite3.DatabaseError:
|
except sqlite3.DatabaseError:
|
||||||
return possible_params
|
return possible_params
|
||||||
|
|
||||||
|
|
||||||
def asyncio_run(coro):
|
|
||||||
if hasattr(asyncio, "run"):
|
|
||||||
# Added in Python 3.7
|
|
||||||
return asyncio.run(coro)
|
|
||||||
else:
|
|
||||||
loop = asyncio.get_event_loop()
|
|
||||||
return loop.run_until_complete(coro)
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue