googleapis / googleapis/google-cloud-python

FixedSizePool.bind unconditionally requests for the same session count on every loop iteration, hence could end up creating much more sessions than necessary; should decrement them per call

Đang mở
#15,908 1 bình luận 0 reaction 1 người được giao Được @larkee nhận Xem trên GitHub
api: spanner
Ngôn ngữ chính
Python
Star
5.4k
Fork
1.8k
Merge trung bình
3 ngày 4 giờ
Pull request đã merge (30 ngày)
122

Mô tả

Found while I was writing tests for PR googleapis/python-spanner#1207 that this code in each iteration requests for the original number of sessions in every loop iteration
https://github.com/googleapis/python-spanner/blob/e15e84f3d18f0e8e635fee38ba62a654c58c9a00/google/cloud/spanner_v1/pool.py#L208-L216
and the basic tests inside tests/unit/test_pool.py when ran, the loop runs twice but each time the count is kept the exact same per https://github.com/googleapis/python-spanner/blob/e15e84f3d18f0e8e635fee38ba62a654c58c9a00/google/cloud/spanner_v1/pool.py#L209-L212

You can add prints and you'll see that the loop runs twice but each time 2 sessions are returned but yet 4 sessions were requested

## Suggestion
The correct remedy for this is that per iteration, the current size of the filled in queue must be considered in relation to filling it up `request.session_count = requested_session_count - self._sessions.qsize()`

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.