You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Calling kr8s.objects.new_class is necessary for Kubernetes object types (e.g. CRDs or other native objects) that kr8s doesn't natively generate classes for. However, you need to assign the class, otherwise by the time you make use of the class, it will have been garbage-collected. A small improvement would be internally cache references to the new class so it doesn't get garbage-collected
The text was updated successfully, but these errors were encountered:
This issue is potentially worked around by #432 as you no longer need to call new_class unless you specifically want to do something with the class that it returns.
The original problem this issue was discussing was around garbage collection when not assigning the result of new_class to anything.
importkr8skr8s.objects.new_class("mutatingwebhookconfiguration", "admissionregistration.k8s.io/v1", namespaced=False, asyncio=False)
# The class created by `new_class` may be garbage collected by the time we get here and the next line will failmwcs=kr8s.get("mutatingwebhookconfigurations.admissionregistration.k8s.io/v1")
As of #432 you don't need to call new_class in this example as the class will be created under the hood automatically.
importkr8s# Just worksmwcs=kr8s.get("mutatingwebhookconfigurations.admissionregistration.k8s.io/v1")
In cases where you explicitly want to call new_class I think it's fair to say you will assign it to something, either because you want to call classmethods on it, or because you want to subclass it.
So I'm going to close out this issue as not-planned as it doesn't feel necessary any more.
Which project are you requesting an enhancement for?
kr8s
What do you need?
For more background, see here
Calling
kr8s.objects.new_class
is necessary for Kubernetes object types (e.g. CRDs or other native objects) thatkr8s
doesn't natively generate classes for. However, you need to assign the class, otherwise by the time you make use of the class, it will have been garbage-collected. A small improvement would be internally cache references to the new class so it doesn't get garbage-collectedThe text was updated successfully, but these errors were encountered: