From 7e4847cf4a061d91ed95014ceb865b03b9e41015 Mon Sep 17 00:00:00 2001 From: Zeev Tarantov Date: Sun, 27 Oct 2019 16:48:15 +0200 Subject: [PATCH] place requests_session as member of handler --- logzio/sender.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/logzio/sender.py b/logzio/sender.py index 4711823..34499ee 100644 --- a/logzio/sender.py +++ b/logzio/sender.py @@ -18,7 +18,6 @@ else: MAX_BULK_SIZE_IN_BYTES = 1 * 1024 * 1024 # 1 MB -requests_session = requests.Session() def backup_logs(logs, logger): @@ -42,6 +41,7 @@ class LogzioSender: self.logger = get_logger(debug) self.backup_logs = backup_logs self.network_timeout = network_timeout + self.requests_session = requests.Session() # Function to see if the main thread is alive self.is_main_thread_active = lambda: any( @@ -111,7 +111,7 @@ class LogzioSender: for current_try in range(number_of_retries): should_retry = False try: - response = requests_session.post( + response = self.requests_session.post( self.url, headers=headers, data='\n'.join(logs_list), timeout=self.network_timeout) if response.status_code != 200: