Skip to content

Commit

Permalink
Fix flake8-bugbear B039 error
Browse files Browse the repository at this point in the history
  • Loading branch information
nsoranzo committed Aug 30, 2024
1 parent 9b010a0 commit cf374eb
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/galaxy/model/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit cf374eb

Please sign in to comment.