@@ -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.
0 commit comments