Skip to content

Commit f075a16

Browse files
Abel Milashclaude
andcommitted
Move close() to _ODataBase and fix MRO order in _ODataClient
- Add _ODataBase.close() to own cache clearing and logger teardown; _ODataClient.close() now delegates via super() then closes _http only - Reorder _ODataClient bases to (_FileUploadMixin, _RelationshipOperationsMixin, _ODataBase) so mixins are searched before the base, matching Python MRO convention Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent a833617 commit f075a16

2 files changed

Lines changed: 18 additions & 7 deletions

File tree

src/PowerPlatform/Dataverse/data/_odata.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
)
4949

5050

51-
class _ODataClient(_ODataBase, _FileUploadMixin, _RelationshipOperationsMixin):
51+
class _ODataClient(_FileUploadMixin, _RelationshipOperationsMixin, _ODataBase):
5252
"""Dataverse Web API client: CRUD, SQL-over-API, and table metadata helpers."""
5353

5454
def __init__(
@@ -88,14 +88,9 @@ def close(self) -> None:
8888
Clears all internal caches and closes the underlying HTTP client.
8989
Safe to call multiple times.
9090
"""
91-
self._logical_to_entityset_cache.clear()
92-
self._logical_primaryid_cache.clear()
93-
self._picklist_label_cache.clear()
91+
super().close()
9492
if self._http is not None:
9593
self._http.close()
96-
if self._http_logger is not None:
97-
self._http_logger.close()
98-
self._http_logger = None
9994

10095
def _headers(self) -> Dict[str, str]:
10196
"""Build standard OData headers with bearer auth."""

src/PowerPlatform/Dataverse/data/_odata_base.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -877,6 +877,22 @@ def _sql_guardrails(self, sql: str) -> str:
877877

878878
return sql
879879

880+
# ------------------------------------------------------------------
881+
# Lifecycle
882+
# ------------------------------------------------------------------
883+
884+
def close(self) -> None:
885+
"""Clear in-memory caches and close the HTTP diagnostic logger.
886+
887+
Called by subclass ``close()`` via ``super()``. Safe to call multiple times.
888+
"""
889+
self._logical_to_entityset_cache.clear()
890+
self._logical_primaryid_cache.clear()
891+
self._picklist_label_cache.clear()
892+
if self._http_logger is not None:
893+
self._http_logger.close()
894+
self._http_logger = None
895+
880896
# ------------------------------------------------------------------
881897
# Cache maintenance
882898
# ------------------------------------------------------------------

0 commit comments

Comments
 (0)