-
Notifications
You must be signed in to change notification settings - Fork 155
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
Lifecycle management of decorators #609
Comments
These are causing warnings in our examples as well: #610. |
Is that true if an alias is used? ie if I use the same alias for multiple decorators will the underlying |
Yes, that should be shared, but the issue is really around the lifecycle of the cache, not the sharing. With an alias, the cache is still created on-demand and users are unlikely to think about closing the cache at any point. I also don't see any real advantage to an alias like that, compared with just passing an explicit reference to the cache object directly. |
Cache objects should be closed at the end of an application lifecycle, with
await Cache.close()
, or usingasync with
.The current design of decorators creates a new cache instance with each decorator and no attempt to close it is made, thus failing to manage this lifecycle management properly.
e.g.
We also want to consider using aiojobs for managing some background tasks, but this additionally requires being created within a running loop, something which is unlikely when a decorator is called.
One solution I can think of, is to explicitly manage the caches, and pass them to the decorators. This may also need a
.start()
method to initiate the cache later. e.g.Or more succinctly:
The text was updated successfully, but these errors were encountered: