Skip to content

Commit

Permalink
fixup! Initialize every connection of http client with session settings
Browse files Browse the repository at this point in the history
  • Loading branch information
mkleen committed Sep 3, 2024
1 parent 9e02aa5 commit c813c65
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions cr8/clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ def _append_sql(host):


class HttpClient:
def __init__(self, hosts, conn_pool_limit=25, session_settings=None):
def __init__(self, hosts, conn_pool_limit=25):
self.hosts = hosts
self.urls = itertools.cycle(list(map(_append_sql, hosts)))
self._connector_params = {
Expand All @@ -324,7 +324,6 @@ def __init__(self, hosts, conn_pool_limit=25, session_settings=None):
}
self.__session = None
self.is_cratedb = True
self.session_settings = session_settings or {}

@property
async def _session(self):
Expand Down Expand Up @@ -386,4 +385,4 @@ def client(hosts, session_settings=None, concurrency=25):
if not asyncpg:
raise ValueError('Cannot use "asyncpg" scheme if asyncpg is not available')
return AsyncpgClient(hosts, pool_size=concurrency, session_settings=session_settings)
return HttpClient(_to_http_hosts(hosts), conn_pool_limit=concurrency, session_settings=session_settings)
return HttpClient(_to_http_hosts(hosts), conn_pool_limit=concurrency)
2 changes: 1 addition & 1 deletion cr8/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def __init__(self, hosts, concurrency, sample_mode, session_settings=None):
self.sampler = get_sampler(sample_mode)
self.session_settings = session_settings

def init(self):
def set_session_settings(self):
if isinstance(self.client, HttpClient):
f = self.client.execute
for setting, value in self.session_settings.items():
Expand Down
2 changes: 1 addition & 1 deletion cr8/run_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def run_queries(self, queries: Iterable[dict], meta=None, session_settings=None)
f' {mode_desc}: {duration or iterations}')
)
with Runner(self.benchmark_hosts, concurrency, self.sample_mode, session_settings) as runner:
runner.init()
runner.set_session_settings()
if warmup > 0:
runner.warmup(stmt, warmup, concurrency, args)
timed_stats = runner.run(
Expand Down

0 comments on commit c813c65

Please sign in to comment.