Skip to content
Open
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
10 changes: 5 additions & 5 deletions mixpanel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,13 +567,10 @@ def __init__(self, events_url=None, people_url=None, import_url=None,
"status_forcelist": set(range(500, 600)),
methods_arg: {"POST"},
}
adapter = requests.adapters.HTTPAdapter(
self._adapter = requests.adapters.HTTPAdapter(
max_retries=urllib3.Retry(**retry_args),
)

self._session = requests.Session()
self._session.mount('http', adapter)

def send(self, endpoint, json_message, api_key=None, api_secret=None):
"""Immediately record an event or a profile update.

Expand Down Expand Up @@ -611,8 +608,11 @@ def _write_request(self, request_url, json_message, api_key=None, api_secret=Non
if api_secret is not None:
basic_auth = HTTPBasicAuth(api_secret, '')

session = requests.Session()
session.mount('http', self._adapter)

try:
response = self._session.post(
response = session.post(
request_url,
data=params,
auth=basic_auth,
Expand Down