File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
sdk/python/feast/infra/registry Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change 1+ import atexit
12import logging
23import threading
34from abc import abstractmethod
@@ -33,7 +34,7 @@ def __init__(
3334 )
3435 self .allow_async_cache = allow_async_cache
3536 if allow_async_cache :
36- threading . Timer ( cache_ttl_seconds , self .refresh ). start ( )
37+ self ._start_async_refresh ( cache_ttl_seconds )
3738
3839 @abstractmethod
3940 def _get_data_source (self , name : str , project : str ) -> DataSource :
@@ -312,3 +313,12 @@ def _refresh_cached_registry_if_necessary(self):
312313 if expired :
313314 logger .info ("Registry cache expired, so refreshing" )
314315 self .refresh ()
316+
317+ def _start_async_refresh (self , cache_ttl_seconds ):
318+ self .registry_refresh_thread = threading .Timer (cache_ttl_seconds , self .refresh )
319+ self .registry_refresh_thread .setDaemon (True )
320+ self .registry_refresh_thread .start ()
321+ atexit .register (self ._exit_handler )
322+
323+ def _exit_handler (self ):
324+ self .registry_refresh_thread .cancel ()
You can’t perform that action at this time.
0 commit comments