diff --git a/lib/galaxy/dependencies/pinned-lint-requirements.txt b/lib/galaxy/dependencies/pinned-lint-requirements.txt index 6aa97f2ab26d..c043874bc5bc 100644 --- a/lib/galaxy/dependencies/pinned-lint-requirements.txt +++ b/lib/galaxy/dependencies/pinned-lint-requirements.txt @@ -1,7 +1,7 @@ -attrs==23.2.0 -flake8==7.1.0 -flake8-bugbear==24.4.26 +attrs==24.2.0 +flake8==7.1.1 +flake8-bugbear==24.8.19 mccabe==0.7.0 -pycodestyle==2.12.0 +pycodestyle==2.12.1 pyflakes==3.2.0 -ruff==0.6.1 +ruff==0.6.3 diff --git a/lib/galaxy/model/base.py b/lib/galaxy/model/base.py index db82a2f9ca78..e1243dda67f5 100644 --- a/lib/galaxy/model/base.py +++ b/lib/galaxy/model/base.py @@ -38,8 +38,7 @@ # of a request (which run within a threadpool) to see changes to the ContextVar # state. See https://github.com/tiangolo/fastapi/issues/953#issuecomment-586006249 # for details -_request_state: Dict[str, str] = {} -REQUEST_ID = ContextVar("request_id", default=_request_state.copy()) +REQUEST_ID: ContextVar[Union[Dict[str, str], None]] = ContextVar("request_id", default=None) @contextlib.contextmanager @@ -112,12 +111,12 @@ def new_session(self): def request_scopefunc(self): """ - Return a value that is used as dictionary key for sqlalchemy's ScopedRegistry. + Return a value that is used as dictionary key for SQLAlchemy's ScopedRegistry. This ensures that threads or request contexts will receive a single identical session from the ScopedRegistry. """ - return REQUEST_ID.get().get("request") or threading.get_ident() + return REQUEST_ID.get({}).get("request") or threading.get_ident() @staticmethod def set_request_id(request_id):