@@ -627,21 +627,26 @@ def sqlq(x: str):
627
627
628
628
# todo(maximsmol): conn resets appear in the startup span and make it last forever
629
629
@trace_function (tracer )
630
- async def reset_conn (x : AsyncConnection [object ], read_only : bool = False ):
630
+ async def reset_conn (
631
+ x : AsyncConnection [object ],
632
+ read_only : bool = False ,
633
+ isolation_level : IsolationLevel = IsolationLevel .SERIALIZABLE ,
634
+ ):
631
635
x .prepare_threshold = 0
632
636
633
637
if x .read_only != read_only :
634
638
await x .set_read_only (read_only )
635
639
636
- if x .isolation_level != IsolationLevel . SERIALIZABLE :
637
- await x .set_isolation_level (IsolationLevel . SERIALIZABLE )
640
+ if x .isolation_level != isolation_level :
641
+ await x .set_isolation_level (isolation_level )
638
642
639
643
640
644
# fixme(maximsmol): use autocommit transactions
641
645
def get_pool (
642
646
config : PostgresConnectionConfig ,
643
647
application_name : str ,
644
648
read_only : bool = True ,
649
+ isolation_level : IsolationLevel = IsolationLevel .SERIALIZABLE ,
645
650
) -> TracedAsyncConnectionPool :
646
651
conn_str = make_conninfo (
647
652
host = config .host ,
@@ -657,7 +662,11 @@ def get_pool(
657
662
max_size = config .pool_size ,
658
663
timeout = timedelta (seconds = 5 ) / timedelta (seconds = 1 ),
659
664
open = False ,
660
- configure = functools .partial (reset_conn , read_only = read_only ),
661
- reset = functools .partial (reset_conn , read_only = read_only ),
665
+ configure = functools .partial (
666
+ reset_conn , read_only = read_only , isolation_level = isolation_level
667
+ ),
668
+ reset = functools .partial (
669
+ reset_conn , read_only = read_only , isolation_level = isolation_level
670
+ ),
662
671
connection_class = LatchAsyncConnection ,
663
672
)
0 commit comments