Skip to content

Commit 182329b

Browse files
jyejarentkathole
authored andcommitted
Using weakref for GRPC session close, avoids Attribute Error
Signed-off-by: jyejare <[email protected]>
1 parent 4349130 commit 182329b

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

sdk/python/feast/infra/registry/remote.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import weakref
23
from datetime import datetime
34
from pathlib import Path
45
from typing import Any, List, Optional, Union
@@ -78,6 +79,7 @@ def __init__(
7879
self.auth_config = auth_config
7980
assert isinstance(registry_config, RemoteRegistryConfig)
8081
self.channel = self._create_grpc_channel(registry_config)
82+
weakref.finalize(self, self.channel.close)
8183

8284
auth_header_interceptor = GrpcClientAuthHeaderInterceptor(auth_config)
8385
self.channel = grpc.intercept_channel(self.channel, auth_header_interceptor)
@@ -107,9 +109,6 @@ def close(self):
107109
if self.channel:
108110
self.channel.close()
109111

110-
def __del__(self):
111-
self.close()
112-
113112
def apply_entity(self, entity: Entity, project: str, commit: bool = True):
114113
request = RegistryServer_pb2.ApplyEntityRequest(
115114
entity=entity.to_proto(), project=project, commit=commit

0 commit comments

Comments
 (0)