# HG changeset patch # User Sylvain Thénault # Date 1489164243 -3600 # Node ID 88bf0ec257b2f8bf38de1346df2955b7c8236e16 # Parent 4c2c731f91909604c7b70337a5b66579de3a1732 [devtools] Stop using repo.new_session diff -r 4c2c731f9190 -r 88bf0ec257b2 cubicweb/devtools/stresstester.py --- a/cubicweb/devtools/stresstester.py Fri Mar 10 18:25:35 2017 +0100 +++ b/cubicweb/devtools/stresstester.py Fri Mar 10 17:44:03 2017 +0100 @@ -54,19 +54,23 @@ from logilab.common.fileutils import lines from logilab.common.ureports import Table, TextWriter + +from cubicweb import repoapi from cubicweb.server.repository import Repository TB_LOCK = threading.Lock() + class QueryExecutor: - def __init__(self, session, times, queries, reporter = None): - self._session = session + + def __init__(self, cnx, times, queries, reporter = None): + self._cnx = cnx self._times = times self._queries = queries self._reporter = reporter def run(self): - with self._session.new_cnx() as cnx: + with self._cnx as cnx: times = self._times while times: for index, query in enumerate(self._queries): @@ -169,12 +173,12 @@ print("Creating repo", prof_file) repo = Repository(config, prof_file) repo.bootstrap() - session = repo.new_session(user, password=password) + cnx = repoapi.connect(repo, user, password=password) reporter = ProfileReporter(queries) if threads > 1: executors = [] while threads: - qe = QueryExecutor(session, repeat, queries, reporter = reporter) + qe = QueryExecutor(cnx, repeat, queries, reporter=reporter) executors.append(qe) thread = threading.Thread(target=qe.run) qe.thread = thread @@ -185,7 +189,7 @@ ## for qe in executors: ## print qe.thread, repeat - qe._times, 'times' else: - QueryExecutor(session, repeat, queries, reporter = reporter).run() + QueryExecutor(cnx, repeat, queries, reporter=reporter).run() reporter.dump_report(report_output)