Skip to content
Open
Show file tree
Hide file tree
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
19 changes: 0 additions & 19 deletions app/clients/sms/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import platform
import socket
from time import monotonic

import requests
from urllib3.connection import HTTPConnection

from app.clients import Client, ClientException


Expand All @@ -30,20 +25,6 @@ def __init__(self, current_app, statsd_client):
self.current_app = current_app
self.statsd_client = statsd_client

self.requests_session = requests.Session()
if platform.system() == "Linux": # these are linux-specific socket options enabling tcp keepalive
for adapter in self.requests_session.adapters.values():
adapter.poolmanager.connection_pool_kw = {
"socket_options": HTTPConnection.default_socket_options
+ [
(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1),
(socket.SOL_TCP, socket.TCP_KEEPIDLE, 4),
(socket.SOL_TCP, socket.TCP_KEEPINTVL, 2),
(socket.SOL_TCP, socket.TCP_KEEPCNT, 8),
],
**adapter.poolmanager.connection_pool_kw,
}

def record_outcome(self, success):
if success:
self.current_app.logger.info("Provider request for %s %s", self.name, "succeeded" if success else "failed")
Expand Down
1 change: 1 addition & 0 deletions app/clients/sms/firetext.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def __init__(self, *args, **kwargs):
self.international_api_key = self.current_app.config.get("FIRETEXT_INTERNATIONAL_API_KEY")
self.url = self.current_app.config.get("FIRETEXT_URL")
self.receipt_url = self.current_app.config.get("FIRETEXT_RECEIPT_URL")
self.requests_session = requests.Session()

def try_send_sms(self, to, content, reference, international, sender):
data = {
Expand Down
1 change: 1 addition & 0 deletions app/clients/sms/mmg.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ def __init__(self, *args, **kwargs):
self.api_key = self.current_app.config.get("MMG_API_KEY")
self.mmg_url = self.current_app.config.get("MMG_URL")
self.receipt_url = self.current_app.config.get("MMG_RECEIPT_URL")
self.requests_session = requests.Session()

def try_send_sms(self, to, content, reference, international, sender):
data = {"reqType": "BULK", "MSISDN": to, "msg": content, "sender": sender, "cid": reference, "multi": True}
Expand Down