Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added usage of subprocess for sending events #60

Merged
merged 3 commits into from
Nov 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
popovaan marked this conversation as resolved.
Show resolved Hide resolved
except Exception as err:
pass # nosec

Expand Down
Loading