diff --git a/src/backend/backend_ga4.py b/src/backend/backend_ga4.py index 376adf6..e7bf474 100644 --- a/src/backend/backend_ga4.py +++ b/src/backend/backend_ga4.py @@ -11,12 +11,21 @@ from .backend import TelemetryBackend from ..utils.cid import get_or_generate_cid, remove_cid_file from ..utils.params import telemetry_params +import multiprocessing + + +def _send_func(request_data): + try: + request.urlopen(request_data) # nosec + except Exception as err: + pass # nosec class GA4Backend(TelemetryBackend): id = 'ga4' cid_filename = 'openvino_ga_cid' old_cid_filename = 'openvino_ga_uid' + timeout = 3.0 def __init__(self, tid: str = None, app_name: str = None, app_version: str = None): super(GA4Backend, self).__init__(tid, app_name, app_version) @@ -43,8 +52,14 @@ def send(self, message: dict): else: log.info("Incorrect backend URL.") return + process = multiprocessing.Process(target=_send_func, args=(req,)) + process.daemon = True + process.start() + + process.join(self.timeout) + if process.is_alive(): + process.terminate() - request.urlopen(req) # nosec except Exception as err: pass # nosec