Skip to content

Commit c1bae1d

Browse files
authored
Fix the telemetry exception handling for daemon mode (#60)
* Fix the telemetry exception handling for daemon mode In daemon mode, the request is made in subprocess effectively causing a huge set of stacktrace in terminal as provided in iterative/studio#11282. This handles the exception properly along with timeout for the telemetry call. Closes iterative/studio#11282 * PR comments * Timeout to 10 * Suppress exception instead
1 parent b6aade5 commit c1bae1d

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/iterative_telemetry/__init__.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,19 @@ def send(
190190
impl(payload)
191191

192192
def _send_daemon(self, payload):
193-
cmd = (
194-
f"import requests;requests.post('{self.url}',"
195-
f"params={{'token':'{self.token}'}},json={payload})"
196-
)
193+
cmd = f"""
194+
import requests
195+
196+
try:
197+
requests.post(
198+
'{self.url}',
199+
params={{'token':'{self.token}'}},
200+
json={payload},
201+
timeout=10
202+
)
203+
except Exception:
204+
pass
205+
"""
197206

198207
if os.name == "nt":
199208

0 commit comments

Comments
 (0)