Skip to content

Commit 8baebaf

Browse files
committed
refactor docstrings
1 parent 52c6fec commit 8baebaf

File tree

3 files changed

+38
-3
lines changed

3 files changed

+38
-3
lines changed

ydb/aio/query/pool.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ async def _create_new_session(self):
4444
return session
4545

4646
async def acquire(self) -> QuerySession:
47+
"""WARNING: This API is experimental and could be changed.
48+
49+
Acquire a session from Session Pool.
50+
51+
:return A QuerySession object.
52+
"""
53+
4754
if self._should_stop.is_set():
4855
logger.error("An attempt to take session from closed session pool.")
4956
raise RuntimeError("An attempt to take session from closed session pool.")
@@ -79,12 +86,18 @@ async def acquire(self) -> QuerySession:
7986
return session
8087

8188
async def release(self, session: QuerySession) -> None:
89+
"""WARNING: This API is experimental and could be changed.
90+
91+
Release a session back to Session Pool.
92+
"""
93+
8294
self._queue.put_nowait(session)
8395
logger.debug("Session returned to queue: %s", session._state.session_id)
8496

8597
def checkout(self) -> "SimpleQuerySessionCheckoutAsync":
8698
"""WARNING: This API is experimental and could be changed.
87-
Return a Session context manager, that opens session on enter and closes session on exit.
99+
100+
Return a Session context manager, that acquires session on enter and releases session on exit.
88101
"""
89102

90103
return SimpleQuerySessionCheckoutAsync(self)
@@ -93,6 +106,7 @@ async def retry_operation_async(
93106
self, callee: Callable, retry_settings: Optional[RetrySettings] = None, *args, **kwargs
94107
):
95108
"""WARNING: This API is experimental and could be changed.
109+
96110
Special interface to execute a bunch of commands with session in a safe, retriable way.
97111
98112
:param callee: A function, that works with session.
@@ -118,6 +132,7 @@ async def execute_with_retries(
118132
**kwargs,
119133
) -> List[convert.ResultSet]:
120134
"""WARNING: This API is experimental and could be changed.
135+
121136
Special interface to execute a one-shot queries in a safe, retriable way.
122137
Note: this method loads all data from stream before return, do not use this
123138
method with huge read queries.

ydb/query/pool.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ class QuerySessionPool:
2929

3030
def __init__(self, driver: common_utils.SupportedDriverType, size: int = 100):
3131
"""
32-
:param driver: A driver instance
32+
:param driver: A driver instance.
33+
:param size: Max size of Session Pool.
3334
"""
3435

3536
logger.warning("QuerySessionPool is an experimental API, which could be changed.")
@@ -47,6 +48,14 @@ def _create_new_session(self, timeout: Optional[float]):
4748
return session
4849

4950
def acquire(self, timeout: Optional[float] = None) -> QuerySession:
51+
"""WARNING: This API is experimental and could be changed.
52+
53+
Acquire a session from Session Pool.
54+
55+
:param timeout: A timeout to wait in seconds.
56+
:return A QuerySession object.
57+
"""
58+
5059
start = time.monotonic()
5160

5261
lock_acquire_timeout = timeout if timeout is not None else -1
@@ -92,18 +101,27 @@ def acquire(self, timeout: Optional[float] = None) -> QuerySession:
92101
self._lock.release()
93102

94103
def release(self, session: QuerySession) -> None:
104+
"""WARNING: This API is experimental and could be changed.
105+
106+
Release a session back to Session Pool.
107+
"""
108+
95109
self._queue.put_nowait(session)
96110
logger.debug("Session returned to queue: %s", session._state.session_id)
97111

98112
def checkout(self, timeout: Optional[float] = None) -> "SimpleQuerySessionCheckout":
99113
"""WARNING: This API is experimental and could be changed.
100-
Return a Session context manager, that opens session on enter and closes session on exit.
114+
115+
Return a Session context manager, that acquires session on enter and releases session on exit.
116+
117+
:param timeout: A timeout to wait in seconds.
101118
"""
102119

103120
return SimpleQuerySessionCheckout(self, timeout)
104121

105122
def retry_operation_sync(self, callee: Callable, retry_settings: Optional[RetrySettings] = None, *args, **kwargs):
106123
"""WARNING: This API is experimental and could be changed.
124+
107125
Special interface to execute a bunch of commands with session in a safe, retriable way.
108126
109127
:param callee: A function, that works with session.
@@ -129,6 +147,7 @@ def execute_with_retries(
129147
**kwargs,
130148
) -> List[convert.ResultSet]:
131149
"""WARNING: This API is experimental and could be changed.
150+
132151
Special interface to execute a one-shot queries in a safe, retriable way.
133152
Note: this method loads all data from stream before return, do not use this
134153
method with huge read queries.

ydb/query/transaction.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@ def execute(
394394
"""WARNING: This API is experimental and could be changed.
395395
396396
Sends a query to Query Service
397+
397398
:param query: (YQL or SQL text) to be executed.
398399
:param parameters: dict with parameters and YDB types;
399400
:param commit_tx: A special flag that allows transaction commit.

0 commit comments

Comments
 (0)