Skip to content

Commit a89cd96

Browse files
committed
Usage statistics: do not crash at any exception
1 parent 9cfa417 commit a89cd96

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

Orange/canvas/__main__.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,13 @@ def send_usage_statistics():
276276

277277
class SendUsageStatistics(QThread):
278278
def run(self):
279-
usage = UsageStatistics()
280-
usage.send_statistics()
279+
try:
280+
usage = UsageStatistics()
281+
usage.send_statistics()
282+
except Exception: # pylint: disable=broad-except
283+
# unhanled exceptions in threads will crash Orange and nothing
284+
# that happens here should
285+
log.warning("Failed to send usage statistics.")
281286

282287
thread = SendUsageStatistics()
283288
thread.start()

Orange/canvas/document/usagestatistics.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222

2323
class UsageStatistics:
24-
"""
24+
q """
2525
Tracks and sends upon close usage statistics when error-reporting/send-statistics is true.
2626
This option can be changed in the preferences menu.
2727
@@ -122,8 +122,6 @@ def send_statistics(self):
122122
json.dump([], f)
123123
except (ConnectionError, requests.exceptions.RequestException):
124124
log.warning("Connection error while attempting to send usage statistics.")
125-
except Exception:
126-
log.warning("Failed to send usage statistics.")
127125

128126
def write_statistics(self):
129127
if not release:

0 commit comments

Comments
 (0)