@@ -1197,6 +1197,7 @@ def __init__(
11971197 instance_id : str ,
11981198 database_id : str ,
11991199 client : Optional [spanner .Client ] = None ,
1200+ timeout : Optional [float ] = None ,
12001201 ):
12011202 """Initializes the Spanner implementation.
12021203
@@ -1208,11 +1209,14 @@ def __init__(
12081209 self .client = client or spanner .Client ()
12091210 self .instance = self .client .instance (instance_id )
12101211 self .database = self .instance .database (database_id )
1212+ self .timeout = timeout
12111213
12121214 def query (self , query : str , params : dict = {}) -> List [Dict [str , Any ]]:
12131215 param_types = {k : TypeUtility .value_to_param_type (v ) for k , v in params .items ()}
12141216 with self .database .snapshot () as snapshot :
1215- rows = snapshot .execute_sql (query , params = params , param_types = param_types )
1217+ rows = snapshot .execute_sql (
1218+ query , params = params , param_types = param_types , timeout = self .timeout
1219+ )
12161220 return [
12171221 {
12181222 column : value
@@ -1253,6 +1257,7 @@ def __init__(
12531257 static_node_properties : List [str ] = [],
12541258 static_edge_properties : List [str ] = [],
12551259 impl : Optional [SpannerInterface ] = None ,
1260+ timeout : Optional [float ] = None ,
12561261 ):
12571262 """Initializes SpannerGraphStore.
12581263
@@ -1267,11 +1272,13 @@ def __init__(
12671272 properties as static;
12681273 static_edge_properties: in flexible schema, treat these edge
12691274 properties as static.
1275+ timeout (Optional[float]): The timeout for queries in seconds.
12701276 """
12711277 self .impl = impl or SpannerImpl (
12721278 instance_id ,
12731279 database_id ,
12741280 client_with_user_agent (client , USER_AGENT_GRAPH_STORE ),
1281+ timeout = timeout ,
12751282 )
12761283 self .schema = SpannerGraphSchema (
12771284 graph_name ,
0 commit comments