Skip to content

Commit 84bb89d

Browse files
committed
Initialize or reset proxy each time before request is sent.
1 parent bcdaf92 commit 84bb89d

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

arho_feature_template/core/lambda_service.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from arho_feature_template.utils.misc_utils import get_active_plan_id, get_plan_name, get_settings
1010

1111

12+
# Luo uusi lambda service kun nappia painaa
1213
class LambdaService(QObject):
1314
jsons_received = pyqtSignal(dict, dict)
1415

@@ -17,19 +18,22 @@ def __init__(self):
1718
# Init network manager
1819
self.network_manager = QNetworkAccessManager()
1920

20-
# Get settings
21+
def send_request(self, action: str, plan_id: str):
22+
"""Sends a request to the lambda function."""
23+
2124
proxy_host, proxy_port, self.lambda_url = get_settings()
2225

26+
# Initialize or reset proxy each time a request is sent. Incase settings have changed.
2327
if proxy_host and proxy_port:
2428
# Set up SOCKS5 Proxy if values are provided
2529
proxy = QNetworkProxy()
2630
proxy.setType(QNetworkProxy.Socks5Proxy)
2731
proxy.setHostName(proxy_host)
2832
proxy.setPort(int(proxy_port))
2933
self.network_manager.setProxy(proxy)
34+
else:
35+
self.network_manager.setProxy(QNetworkProxy())
3036

31-
def send_request(self, action: str, plan_id: str):
32-
"""Sends a request to the lambda function."""
3337
payload = {"action": action, "plan_uuid": plan_id}
3438
payload_bytes = QByteArray(json.dumps(payload).encode("utf-8"))
3539

0 commit comments

Comments
 (0)