Skip to content

Commit fab0f57

Browse files
authored
fix: REST client should not close after stream request (#172)
1 parent 2db7d04 commit fab0f57

File tree

4 files changed

+1
-14
lines changed

4 files changed

+1
-14
lines changed

openfga_sdk/rest.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -409,9 +409,6 @@ async def stream(
409409
# Release the response object (required!)
410410
response.release()
411411

412-
# Release the connection back to the pool
413-
await self.close()
414-
415412
async def request(
416413
self,
417414
method: str,

openfga_sdk/sync/rest.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -452,9 +452,6 @@ def stream(
452452
# Release the response object (required!)
453453
response.release_conn()
454454

455-
# Release the connection back to the pool
456-
self.close()
457-
458455
def request(
459456
self,
460457
method: str,

test/rest_test.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,6 @@ async def iter_chunks(self):
319319

320320
client.handle_response_exception.assert_awaited_once()
321321
mock_response.release.assert_called_once()
322-
client.close.assert_awaited_once()
323322

324323

325324
@pytest.mark.asyncio
@@ -364,7 +363,6 @@ async def iter_chunks(self):
364363
assert results == []
365364
client.handle_response_exception.assert_awaited_once()
366365
mock_response.release.assert_called_once()
367-
client.close.assert_awaited_once()
368366

369367

370368
@pytest.mark.asyncio
@@ -411,4 +409,3 @@ async def iter_chunks(self):
411409

412410
client.handle_response_exception.assert_awaited_once()
413411
mock_response.release.assert_called_once()
414-
client.close.assert_awaited_once()

test/sync/rest_test.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ def test_close():
288288
client.pool_manager = mock_pool_manager
289289

290290
client.close()
291+
291292
mock_pool_manager.clear.assert_called_once()
292293

293294

@@ -333,7 +334,6 @@ def test_request_preload_content():
333334
assert isinstance(resp, RESTResponse)
334335
assert resp.status == 200
335336
assert resp.data == b'{"some":"data"}'
336-
mock_pool_manager.clear.assert_called_once()
337337

338338

339339
def test_request_no_preload_content():
@@ -380,7 +380,6 @@ def test_request_no_preload_content():
380380
# We expect the raw HTTPResponse
381381
assert resp == mock_raw_response
382382
assert resp.status == 200
383-
mock_pool_manager.clear.assert_called_once()
384383

385384

386385
def test_stream_happy_path():
@@ -431,7 +430,6 @@ def release_conn(self):
431430

432431
assert results == [{"foo": "bar"}, {"hello": "world"}]
433432
mock_pool_manager.request.assert_called_once()
434-
mock_pool_manager.clear.assert_called_once()
435433

436434

437435
def test_stream_partial_chunks():
@@ -483,7 +481,6 @@ def release_conn(self):
483481

484482
assert results == [{"foo": "bar"}, {"hello": "world"}]
485483
mock_pool_manager.request.assert_called_once()
486-
mock_pool_manager.clear.assert_called_once()
487484

488485

489486
def test_stream_exception_in_chunks():
@@ -534,4 +531,3 @@ def release_conn(self):
534531
# Exception is logged, we yield nothing
535532
assert results == []
536533
mock_pool_manager.request.assert_called_once()
537-
mock_pool_manager.clear.assert_called_once()

0 commit comments

Comments
 (0)