Skip to content

Commit

Permalink
Added usage of subprocess for sending events (#60)
Browse files Browse the repository at this point in the history
* Added subprocess usage for sending.

* Fixed error.

* Minor corrections.
  • Loading branch information
popovaan authored Nov 19, 2024
1 parent 1f98695 commit 1216f13
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/backend/backend_ga4.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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

Expand Down

0 comments on commit 1216f13

Please sign in to comment.