fix #1246: catch exceptions caused by GA report failure

This commit is contained in:
debugtalk
2022-04-30 15:00:57 +08:00
parent 6af68be8be
commit 737379b49f
2 changed files with 9 additions and 2 deletions
+1
View File
@@ -3,6 +3,7 @@
## 2.5.9 (2022-04-30) ## 2.5.9 (2022-04-30)
- fix #1217: reload debugtalk.py if loaded - fix #1217: reload debugtalk.py if loaded
- fix #1246: catch exceptions caused by GA report failure
## 2.5.8 (2022-03-23) ## 2.5.8 (2022-03-23)
+8 -2
View File
@@ -55,7 +55,10 @@ class GAClient(object):
'ev': value, # Optional. Event value, must be non-negative integer 'ev': value, # Optional. Event value, must be non-negative integer
} }
data.update(self.common_params) data.update(self.common_params)
self.http_client.post(self.report_url, data=data) try:
self.http_client.post(self.report_url, data=data, timeout=5)
except Exception: # ProxyError, SSLError, ConnectionError
pass
def track_user_timing(self, category, variable, duration): def track_user_timing(self, category, variable, duration):
data = { data = {
@@ -66,7 +69,10 @@ class GAClient(object):
'utl': self.label, # Optional. user timing label, used as version. 'utl': self.label, # Optional. user timing label, used as version.
} }
data.update(self.common_params) data.update(self.common_params)
self.http_client.post(self.report_url, data=data) try:
self.http_client.post(self.report_url, data=data, timeout=5)
except Exception: # ProxyError, SSLError, ConnectionError
pass
ga_client = GAClient("UA-114587036-1") ga_client = GAClient("UA-114587036-1")