Skip to content

Commit 5bcca80

Browse files
committed
feat: improve smoke test to run queries in parallel
1 parent 9adcf84 commit 5bcca80

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

tests/smoke.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# A simple smoke test for the DB driver.
22

33
import argparse
4+
import concurrent.futures
45
import functools
56
import logging
67
import sys
@@ -11,6 +12,7 @@
1112

1213
from wherobots.db import connect, connect_direct
1314
from wherobots.db.constants import DEFAULT_ENDPOINT
15+
from wherobots.db.connection import Connection
1416
from wherobots.db.region import Region
1517
from wherobots.db.runtime import Runtime
1618

@@ -85,8 +87,13 @@ def render(results: pandas.DataFrame):
8587
table.add_row(*r)
8688
Console().print(table)
8789

90+
def execute(conn: Connection, sql: str) -> pandas.DataFrame:
91+
with conn.cursor() as cursor:
92+
cursor.execute(sql)
93+
return cursor.fetchall()
94+
8895
with conn_func() as conn:
89-
for sql in args.sql:
90-
with conn.cursor() as cursor:
91-
cursor.execute(sql)
92-
render(cursor.fetchall())
96+
with concurrent.futures.ThreadPoolExecutor() as pool:
97+
futures = [pool.submit(execute, conn, s) for s in args.sql]
98+
for future in concurrent.futures.as_completed(futures):
99+
render(future.result())

0 commit comments

Comments
 (0)