Skip to content

Commit 7b8e1f0

Browse files
Upgrade FastAPI to solve memory leaks (#43)
* Upgrade FastAPI to solve memory leaks * Add changelog notice * Fix rerouting of WSGI webview
1 parent 90b3e82 commit 7b8e1f0

8 files changed

Lines changed: 23 additions & 8 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ __pycache__
1010
.coverage
1111
.mypy_cache
1212
/venv
13+
/rt-venv
1314

1415
*.zip

docs/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All **user-facing**, notable changes will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [2.14.2] - 2024-04-04
8+
### Fixed
9+
- FastAPI dependency has been upgraded to solve memory leaks.
10+
711
## [2.14.0] - 2024-03-25
812
### Added
913
- Maximum number of concurrent requests can be limited by `max_concurrency` field in a manifest:

src/plugin-manifest.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
name: python3-job-type
2-
version: 2.14.0
2+
version: 2.14.2
33
url: 'https://github.com/TheRacetrack/plugin-python-job-type'
44
category: 'job-type'

src/python_wrapper/racetrack_commons/api/asgi/proxy.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,13 @@ async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None:
3737
@classmethod
3838
def mount_path(cls, path: str):
3939
cls.forwarded_paths.add(path)
40+
41+
42+
class DebugASGIRouting:
43+
def __init__(self, app: ASGIApp) -> None:
44+
self.app = app
45+
46+
async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None:
47+
path = scope['path']
48+
print(f'ASGI route: {path}')
49+
await self.app(scope, receive, send)
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
prometheus-client==0.17.1
22
pydantic==2.6.1
33
pyjwt[crypto]==2.6.0
4-
fastapi==0.109.2
5-
uvicorn[standard]==0.24.0
4+
fastapi==0.110.1
5+
uvicorn[standard]==0.29.0
66
opentelemetry-exporter-otlp-proto-http==1.16.0
77
protobuf==4.22.0 # needed by opentelemetry exporter
8-
python-multipart==0.0.6 # uploading files
8+
python-multipart==0.0.9 # uploading files
99
watchdog==2.3.1
10-
a2wsgi==1.7.0
10+
a2wsgi==1.10.4

src/python_wrapper/racetrack_job_wrapper/webview.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def setup_webview_endpoints(
3030
# Determine whether webview app is WSGI or ASGI
3131
sig = signature(webview_app)
3232
if len(sig.parameters) == 2:
33-
webview_app = PathPrefixerWSGIMiddleware(webview_app, base_url)
33+
webview_app = PathPrefixerWSGIMiddleware(webview_app, webview_base_url)
3434
webview_app = WSGIMiddleware(webview_app)
3535
logger.debug(f'Webview app recognized as a WSGI app')
3636
else:
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
PyYAML==6.0
2-
a2wsgi==1.7.0
2+
a2wsgi==1.10.4
33
httpx==0.24.0

src/python_wrapper/tests/wrap/test_webview.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def test_requesting_webview_wsgi_pages(revert_workdir):
2626
client = TestClient(api_app)
2727

2828
response = client.get('/pub/job/skynet/0.0.1/api/v1/webview')
29-
assert response.status_code == 200, 'webview without a slash is forwarded automatically'
29+
assert response.status_code == 200, f'webview without a slash is forwarded automatically, response: {response.text}'
3030
html = response.text
3131
assert 'Hello world. Here\'s a webview' in html, 'webview returns HTML'
3232

0 commit comments

Comments
 (0)