forked from p15670423/monkey
Island: Run analytics request asynchronously
This commit is contained in:
parent
0c39268668
commit
6da38e341f
|
@ -3,6 +3,7 @@ import json
|
||||||
import logging
|
import logging
|
||||||
import sys
|
import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from threading import Thread
|
||||||
from typing import Sequence, Tuple
|
from typing import Sequence, Tuple
|
||||||
|
|
||||||
import gevent.hub
|
import gevent.hub
|
||||||
|
@ -225,6 +226,7 @@ ANALYTICS_URL = (
|
||||||
|
|
||||||
|
|
||||||
def _send_analytics(deployment: Deployment, version: Version):
|
def _send_analytics(deployment: Deployment, version: Version):
|
||||||
|
def _inner(deployment: Deployment, version: Version):
|
||||||
url = ANALYTICS_URL.format(deployment=deployment.value, version=version.version_number)
|
url = ANALYTICS_URL.format(deployment=deployment.value, version=version.version_number)
|
||||||
try:
|
try:
|
||||||
response = requests.get(url).json()
|
response = requests.get(url).json()
|
||||||
|
@ -236,3 +238,5 @@ def _send_analytics(deployment: Deployment, version: Version):
|
||||||
logger.info(
|
logger.info(
|
||||||
f"Failed to send deployment type and version number to the analytics server: {err}"
|
f"Failed to send deployment type and version number to the analytics server: {err}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Thread(target=_inner, args=(deployment, version), daemon=True).start()
|
||||||
|
|
Loading…
Reference in New Issue