-
Notifications
You must be signed in to change notification settings - Fork 3
CU-869ah00vt Fix memory leak (mc-service) #141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 14 commits
a44703b
09a4f9f
7cd6cc5
bdaeaf7
6428a16
6a6eef4
db6a131
73d8c4b
6dc73f8
393d182
f573b4d
6bd3fda
9493de4
1c75c68
d40b261
9cbe7fd
ea8f55d
8d2947f
4534172
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,14 +10,14 @@ | |
| log = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| @lru_cache | ||
| @lru_cache(maxsize=1) | ||
| def get_settings() -> Settings: | ||
| settings = Settings() | ||
| log.debug("Using settings: %s", settings) | ||
| return settings | ||
|
|
||
|
|
||
| @lru_cache | ||
| @lru_cache(maxsize=1) | ||
|
||
| def get_medcat_processor(settings: Annotated[Settings, Depends(get_settings)]) -> MedCatProcessor: | ||
| log.debug("Creating new Medcat Processsor using settings: %s", settings) | ||
| return MedCatProcessor(settings) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refer to the comment below for more detail.
Perhaps we can get away with something simpler for the settings singleton, i.e
That way the
get_settingsmethod will always return the same instance and thus the caching forget_medcat_processorshould always result in the same instance since the argument is always the same.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense to me, feels right to make it explicitly a global singleton. Would keep that log line in from before and really confirm it never gets created again
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, if we fully force a singleton settings instance, I fail to see how we could ever have multiple
MedCATProcessorinstances from the cached method.But yes, keeping the log message does still make sense!