Skip to content

Commit 1d1e312

Browse files
committed
QuerySessionPool docstring
1 parent 6b07d63 commit 1d1e312

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

ydb/query/pool.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,26 @@ def retry_operation_impl(callee: Callable, retry_settings: RetrySettings = None,
9696

9797

9898
class QuerySessionPool:
99+
"""QuerySessionPool is an object to simplify operations with sessions of Query Service."""
100+
99101
def __init__(self, driver: base.SupportedDriverType):
102+
"""
103+
:param driver: A driver instance
104+
"""
100105
self._driver = driver
101106

102107
def checkout(self):
108+
"""Return a Session context manager, that opens session on enter and closes session on exit."""
103109
return SimpleQuerySessionCheckout(self)
104110

105111
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+
"""
106119
retry_settings = RetrySettings() if retry_settings is None else retry_settings
107120

108121
def wrapped_callee():
@@ -117,6 +130,13 @@ def wrapped_callee():
117130
return next_opt.result
118131

119132
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+
"""
120140
retry_settings = RetrySettings() if retry_settings is None else retry_settings
121141
with self.checkout() as session:
122142

0 commit comments

Comments
 (0)