Skip to content

Commit

Permalink
Stop running queries in parallel, refs #2189
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Sep 21, 2023
1 parent c0227ac commit c0d58a7
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions datasette/views/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,20 +172,14 @@ async def _data_traced(
raise NotFound("Database not found: {}".format(database_route))
database_name = db.name

# For performance profiling purposes, ?_noparallel=1 turns off asyncio.gather
async def _gather_parallel(*args):
return await asyncio.gather(*args)

async def _gather_sequential(*args):
# We always now run queries sequentially, rather than with asyncio.gather() -
# see https://github.com/simonw/datasette/issues/2189
async def gather(*args):
results = []
for fn in args:
results.append(await fn)
return results

gather = (
_gather_sequential if request.args.get("_noparallel") else _gather_parallel
)

# If this is a canned query, not a table, then dispatch to QueryView instead
canned_query = await self.ds.get_canned_query(
database_name, table_name, request.actor
Expand Down

0 comments on commit c0d58a7

Please sign in to comment.