Skip to content

Commit c54efb2

Browse files
authored
refactor: _load_legacy_wsgi now internally resolves its config file path instead of receiving it as an argument. fastapi (#11484)
1 parent 7cd7f84 commit c54efb2

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

openlibrary/asgi_app.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def wrapper(environ, start_response):
3636
return wrapper
3737

3838

39-
def _load_legacy_wsgi(ol_config_file: str):
39+
def _load_legacy_wsgi():
4040
"""Initialize legacy configuration and side-effects as in scripts/openlibrary-server.
4141
4242
This function does not return a WSGI callable; it is called for its side effects only.
@@ -47,6 +47,9 @@ def _load_legacy_wsgi(ol_config_file: str):
4747
# match scripts/openlibrary-server behavior
4848
from infogami.utils import delegate as _delegate # noqa: F401 - side-effects
4949

50+
ol_config_path = Path(__file__).parent / "conf" / "openlibrary.yml"
51+
ol_config_file = os.environ.get("OL_CONFIG", str(ol_config_path))
52+
5053
config.plugin_path += ["openlibrary.plugins"]
5154
config.site = "openlibrary.org"
5255

@@ -124,11 +127,9 @@ def create_app() -> FastAPI:
124127

125128
pytest.skip("Skipping in CI", allow_module_level=True)
126129

127-
ol_config_path = Path(__file__).parent / "conf" / "openlibrary.yml"
128-
ol_config = os.environ.get("OL_CONFIG", str(ol_config_path))
129130
try:
130131
# We still call this even though we don't use it because of the side effects
131-
legacy_wsgi = _load_legacy_wsgi(ol_config) # noqa: F841
132+
_load_legacy_wsgi()
132133

133134
global sentry
134135
if sentry is not None:

0 commit comments

Comments
 (0)