You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/02/26 14:40:18 UTC

[GitHub] [airflow] ashb commented on a change in pull request #14454: lazy load stats logger instance

ashb commented on a change in pull request #14454:
URL: https://github.com/apache/airflow/pull/14454#discussion_r583684820



##########
File path: airflow/stats.py
##########
@@ -348,25 +348,28 @@ def timer(self, stat=None, *args, tags=None, **kwargs):
 
 
 class _Stats(type):
+    factory = None
     instance: Optional[StatsLogger] = None
 
     def __getattr__(cls, name):
+        if not cls.instance:
+            try:
+                cls.instance = cls.factory()
+            except (socket.gaierror, ImportError) as e:
+                log.error("Could not configure StatsClient: %s, using DummyStatsLogger instead.", e)

Review comment:
       If a stats backend _isn't_ configured, isn't factory going to be None, and so we'd die with a TypeError?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org