@@ -96,13 +96,26 @@ def retry_operation_impl(callee: Callable, retry_settings: RetrySettings = None,
96
96
97
97
98
98
class QuerySessionPool :
99
+ """QuerySessionPool is an object to simplify operations with sessions of Query Service."""
100
+
99
101
def __init__ (self , driver : base .SupportedDriverType ):
102
+ """
103
+ :param driver: A driver instance
104
+ """
100
105
self ._driver = driver
101
106
102
107
def checkout (self ):
108
+ """Return a Session context manager, that opens session on enter and closes session on exit."""
103
109
return SimpleQuerySessionCheckout (self )
104
110
105
111
def retry_operation_sync (self , callee : Callable , retry_settings : RetrySettings = None , * args , ** kwargs ):
112
+ """Special interface to execute a bunch of commands with session in a safe, retriable way.
113
+
114
+ :param callee: A function, that works with session.
115
+ :param retry_settings: RetrySettings object.
116
+
117
+ :return: Result sets or exception in case of execution errors.
118
+ """
106
119
retry_settings = RetrySettings () if retry_settings is None else retry_settings
107
120
108
121
def wrapped_callee ():
@@ -117,6 +130,13 @@ def wrapped_callee():
117
130
return next_opt .result
118
131
119
132
def execute_with_retries (self , query : str , retry_settings : RetrySettings = None , * args , ** kwargs ):
133
+ """Special interface to execute a one-shot queries in a safe, retriable way.
134
+
135
+ :param query: A query, yql or sql text.
136
+ :param retry_settings: RetrySettings object.
137
+
138
+ :return: Result sets or exception in case of execution errors.
139
+ """
120
140
retry_settings = RetrySettings () if retry_settings is None else retry_settings
121
141
with self .checkout () as session :
122
142
0 commit comments