Skip to content

Commit

Permalink
Reorder async refresh call
Browse files Browse the repository at this point in the history
Signed-off-by: Stanley Opara <[email protected]>
  • Loading branch information
Stanley Opara committed Jun 12, 2024
1 parent 2f8b3ef commit a264d64
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sdk/python/feast/infra/registry/caching_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def __init__(self, project: str, cache_ttl_seconds: int, cache_mode: str):
self.cache_mode = cache_mode
if cache_mode == "thread":
self._start_thread_async_refresh(cache_ttl_seconds)
atexit.register(self._exit_handler)

@abstractmethod
def _get_data_source(self, name: str, project: str) -> DataSource:
Expand Down Expand Up @@ -312,15 +313,14 @@ def _refresh_cached_registry_if_necessary(self):
self.refresh()

def _start_thread_async_refresh(self, cache_ttl_seconds):
self.refresh()
if cache_ttl_seconds <= 0:
return
self.refresh()
self.registry_refresh_thread = threading.Timer(
cache_ttl_seconds, self._start_thread_async_refresh, [cache_ttl_seconds]
)
self.registry_refresh_thread.setDaemon(True)
self.registry_refresh_thread.start()
atexit.register(self._exit_handler)

def _exit_handler(self):
self.registry_refresh_thread.cancel()

0 comments on commit a264d64

Please sign in to comment.