Island: Run analytics request asynchronously

This commit is contained in:
Mike Salvatore 2022-08-12 11:49:16 -04:00
parent 0c39268668
commit 6da38e341f
1 changed files with 15 additions and 11 deletions

View File

@ -3,6 +3,7 @@ import json
import logging
import sys
from pathlib import Path
from threading import Thread
from typing import Sequence, Tuple
import gevent.hub
@ -225,6 +226,7 @@ ANALYTICS_URL = (
def _send_analytics(deployment: Deployment, version: Version):
def _inner(deployment: Deployment, version: Version):
url = ANALYTICS_URL.format(deployment=deployment.value, version=version.version_number)
try:
response = requests.get(url).json()
@ -236,3 +238,5 @@ def _send_analytics(deployment: Deployment, version: Version):
logger.info(
f"Failed to send deployment type and version number to the analytics server: {err}"
)
Thread(target=_inner, args=(deployment, version), daemon=True).start()