Skip to content

Commit 6a6b223

Browse files
committed
refactor docstrings
1 parent 52c6fec commit 6a6b223

File tree

6 files changed

+43
-3
lines changed

6 files changed

+43
-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/aio/query/session.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ async def execute(
116116
"""WARNING: This API is experimental and could be changed.
117117
118118
Sends a query to Query Service
119+
119120
:param query: (YQL or SQL text) to be executed.
120121
:param syntax: Syntax of the query, which is a one from the following choises:
121122
1) QuerySyntax.YQL_V1, which is default;

ydb/aio/query/transaction.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ async def execute(
114114
"""WARNING: This API is experimental and could be changed.
115115
116116
Sends a query to Query Service
117+
117118
:param query: (YQL or SQL text) to be executed.
118119
:param parameters: dict with parameters and YDB types;
119120
:param commit_tx: A special flag that allows transaction commit.

ydb/query/pool.py

Lines changed: 22 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,15 @@ 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+
57+
:return A QuerySession object.
58+
"""
59+
5060
start = time.monotonic()
5161

5262
lock_acquire_timeout = timeout if timeout is not None else -1
@@ -92,18 +102,27 @@ def acquire(self, timeout: Optional[float] = None) -> QuerySession:
92102
self._lock.release()
93103

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

98113
def checkout(self, timeout: Optional[float] = None) -> "SimpleQuerySessionCheckout":
99114
"""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.
115+
116+
Return a Session context manager, that acquires session on enter and releases session on exit.
117+
118+
:param timeout: A timeout to wait in seconds.
101119
"""
102120

103121
return SimpleQuerySessionCheckout(self, timeout)
104122

105123
def retry_operation_sync(self, callee: Callable, retry_settings: Optional[RetrySettings] = None, *args, **kwargs):
106124
"""WARNING: This API is experimental and could be changed.
125+
107126
Special interface to execute a bunch of commands with session in a safe, retriable way.
108127
109128
:param callee: A function, that works with session.
@@ -129,6 +148,7 @@ def execute_with_retries(
129148
**kwargs,
130149
) -> List[convert.ResultSet]:
131150
"""WARNING: This API is experimental and could be changed.
151+
132152
Special interface to execute a one-shot queries in a safe, retriable way.
133153
Note: this method loads all data from stream before return, do not use this
134154
method with huge read queries.

ydb/query/session.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ def transaction(self, tx_mode: Optional[base.BaseQueryTxMode] = None) -> QueryTx
269269
"""WARNING: This API is experimental and could be changed.
270270
271271
Creates a transaction context manager with specified transaction mode.
272+
272273
:param tx_mode: Transaction mode, which is a one from the following choises:
273274
1) QuerySerializableReadWrite() which is default mode;
274275
2) QueryOnlineReadOnly(allow_inconsistent_reads=False);
@@ -301,6 +302,7 @@ def execute(
301302
"""WARNING: This API is experimental and could be changed.
302303
303304
Sends a query to Query Service
305+
304306
:param query: (YQL or SQL text) to be executed.
305307
:param syntax: Syntax of the query, which is a one from the following choises:
306308
1) QuerySyntax.YQL_V1, which is default;

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)