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,14 +226,17 @@ ANALYTICS_URL = (
def _send_analytics(deployment: Deployment, version: Version):
url = ANALYTICS_URL.format(deployment=deployment.value, version=version.version_number)
try:
response = requests.get(url).json()
logger.info(
f"Version number and deployment type was sent to analytics server. "
f"The response is: {response}"
)
except requests.exceptions.ConnectionError as err:
logger.info(
f"Failed to send deployment type and version number to the analytics server: {err}"
)
def _inner(deployment: Deployment, version: Version):
url = ANALYTICS_URL.format(deployment=deployment.value, version=version.version_number)
try:
response = requests.get(url).json()
logger.info(
f"Version number and deployment type was sent to analytics server. "
f"The response is: {response}"
)
except requests.exceptions.ConnectionError as err:
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()