Skip to content

Commit ce11688

Browse files
committed
Fix review comments
1 parent 577ee11 commit ce11688

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

reportportal_client/_internal/aio/http.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ async def __request(self, method: Callable, url, **kwargs: Any) -> ClientRespons
9999

100100
for i in range(self.__retry_number + 1): # add one for the first attempt, which is not a retry
101101
retry_factor = None
102+
if result is not None:
103+
# Close previous result if it's retried to release resources
104+
result.close()
102105
try:
103106
result = await method(url, **kwargs)
104107
except Exception as exc:
@@ -207,6 +210,8 @@ async def __request(self, method: Callable, url: str, **kwargs: Any) -> ClientRe
207210
if result.status in AUTH_PROBLEM_STATUSES and self.__auth:
208211
refreshed_header = await self.__auth.refresh()
209212
if refreshed_header:
213+
# Close previous result if it's retried to release resources
214+
result.close()
210215
# Retry with new auth header
211216
request_kwargs["headers"] = request_kwargs.get("headers", {}).copy()
212217
request_kwargs["headers"]["Authorization"] = refreshed_header

reportportal_client/_internal/services/statistics.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ def send_event(
9595
)
9696
except requests.exceptions.RequestException as err:
9797
logger.debug("Failed to send data to Statistics service: %s", str(err))
98+
return None
9899

99100

100101
async def async_send_event(
@@ -121,7 +122,7 @@ async def async_send_event(
121122
ssl=ssl_context,
122123
)
123124
except aiohttp.ClientError as exc:
124-
logger.debug("Failed to send data to Statistics service: connection error", exc)
125+
logger.debug("Failed to send data to Statistics service: %s", str(exc))
125126
return None
126127
if not result.ok:
127128
logger.debug(f"Failed to send data to Statistics service: {result.reason}")

tests/_internal/services/test_auth.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License
1616

17+
import asyncio
1718
import time
1819
from unittest import mock
1920

@@ -326,7 +327,7 @@ async def test_happy_path_token_refresh(self):
326327
assert mock_session.post.call_count == 1
327328

328329
# Wait for token to expire
329-
time.sleep(1)
330+
await asyncio.sleep(1)
330331

331332
# Second call - token expired, should refresh
332333
new_access_token = "new_access_token"

0 commit comments

Comments
 (0)