Skip to content

Commit

Permalink
make cem timeout configurable (#116)
Browse files Browse the repository at this point in the history
CPNHUB-245
  • Loading branch information
petrjasek authored Jun 30, 2023
1 parent 741e476 commit 9e9e124
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
4 changes: 4 additions & 0 deletions server/cp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,9 @@
# AUTHORS and LICENSE files distributed with this source code, or
# at https://www.sourcefabric.org/superdesk/license

import logging

HEADLINE2 = "headline_extended"
CORRECTION = "correction"

logging.basicConfig(level=logging.INFO)
22 changes: 15 additions & 7 deletions server/cp/cem.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import logging
import requests

from flask import current_app as app


logger = logging.getLogger(__name__)
session = requests.Session()


Expand All @@ -18,10 +21,15 @@ def send_notification(_type, user):
}
if user.get("company"):
payload["company"] = str(user["company"])
session.patch(
url,
timeout=5,
json=payload,
headers=headers,
verify=bool(app.config.get("CEM_VERIFY_TLS", True)),
)
try:
session.patch(
url,
json=payload,
headers=headers,
timeout=int(app.config.get("CEM_TIMEOUT", 10)),
verify=bool(app.config.get("CEM_VERIFY_TLS", True)),
)
except requests.exceptions.RequestException as err:
logger.error(err)
return
logger.info("Notification sent to CEM")
1 change: 1 addition & 0 deletions server/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,5 +273,6 @@
CEM_APIKEY = os.environ.get("CEM_APIKEY", "")
CEM_PLATFORM = os.environ.get("CEM_PLATFORM", "NewsPro")
CEM_VERIFY_TLS = strtobool(os.environ.get("CEM_VERIFY_TLS", "off"))
CEM_TIMEOUT = int(os.environ.get("CEM_TIMEOUT") or 10)

DEFAULT_ALLOW_COMPANIES_TO_MANAGE_PRODUCTS = True

0 comments on commit 9e9e124

Please sign in to comment.