fix: remove stateful instance caching from endpoints for thread-safety#942
fix: remove stateful instance caching from endpoints for thread-safety#942Copilot wants to merge 3 commits into
Conversation
Removes self._cache and all associated caching logic from GenericListGetEndpoint. Every list()/async_list() call now performs a fresh API request, eliminating race conditions and cross-request data leaks in concurrent environments. - Remove self._cache, _get_local_cache, _update_local_cache, _check_cache_hit - Remove refresh parameter from _list_sync, _list_async, _prepare_list_request - Simplify ListRequestState struct (remove cache, cached_result, has_filters fields) - Remove _enable_cache attribute from EndpointABC, EndpointProtocol - Remove refresh=True from FilterGetOperation and validation/cache.py list calls - Remove _enable_cache = True from studies, forms, variables, intervals endpoints - Update all tests to reflect stateless behavior - Update docs/caching.rst to document removal of native endpoint caching Agent-Logs-Url: https://github.com/fderuiter/imednet-python-sdk/sessions/372392a9-115d-44c0-ba22-f82f5556f061 Co-authored-by: fderuiter <127706008+fderuiter@users.noreply.github.com>
|
@copilot Job Failure: The workflow runs: poetry run black --check .
poetry run isort --check --profile black .So the issue is not a test failure; it is a Black formatting failure in: The likely offending line is this long assertion near the end of the file: client.post.assert_called_once_with(
"/create", json=[{"field1": "val1"}], headers={HEADER_EMAIL_NOTIFY: "user@example.com"}
)Black would reformat it to: client.post.assert_called_once_with(
"/create",
json=[{"field1": "val1"}],
headers={HEADER_EMAIL_NOTIFY: "user@example.com"},
)Apply that change in You can also let Black fix it automatically: poetry run black tests/unit/test_core_endpoint_operations.pyThen verify locally with: poetry run black --check .
poetry run isort --check --profile black .No workflow change is needed; the job is correctly enforcing formatting. |
Agent-Logs-Url: https://github.com/fderuiter/imednet-python-sdk/sessions/6ad97d01-e771-4e35-a29e-6c640cf78df2 Co-authored-by: fderuiter <127706008+fderuiter@users.noreply.github.com>
Fixed in 69ac685. Black collapsed the two short |
GenericListGetEndpointheld aself._cachedict mutated on everylist()call, creating race conditions and cross-request data leaks when the SDK is shared across threads (FastAPI, Airflow workers, etc.).Changes
Removed caching infrastructure
self._cache,_get_local_cache(),_update_local_cache(),_check_cache_hit()deleted fromGenericListGetEndpoint_enable_cacheclass attribute removed fromEndpointABCandEndpointProtocolrefreshparameter removed from_list_sync,_list_async,_prepare_list_request, andListEndpointProtocolcache,cached_result,has_filtersfields removed fromListRequestStateEndpoint cleanup
_enable_cache = Trueremoved fromStudiesEndpoint,FormsEndpoint,VariablesEndpoint,IntervalsEndpointDownstream callers updated
FilterGetOperation.execute_sync/execute_async: droppedrefresh=Truefrom list callsvalidation/cache.py(SchemaValidator,AsyncSchemaValidator,SchemaCache): droppedrefresh=Truefrom allvariables.list()/variables.async_list()callsDocs
docs/caching.rst: replaces the "Endpoint Caches" section with a note that endpoint caching has been removed; directs consumers to application-layer solutions (cachetools,httpx-cache, framework caches)Every
list()/async_list()call now performs a fresh HTTP request. Callers that relied onrefresh=Trueto bypass the cache simply pass norefreshargument.