From 12aa9972dc28691203d7a3d778108e6c7a59cee0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hrvoje=20Milkovi=C4=87?= Date: Mon, 7 Jun 2021 19:47:17 +0200 Subject: [PATCH] [7.x] Reraise RecursionError in Transport.perform_request() --- elasticsearch/_async/http_aiohttp.py | 5 ++--- elasticsearch/connection/http_requests.py | 2 ++ elasticsearch/connection/http_urllib3.py | 2 ++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/elasticsearch/_async/http_aiohttp.py b/elasticsearch/_async/http_aiohttp.py index 64060293..2057cdd6 100644 --- a/elasticsearch/_async/http_aiohttp.py +++ b/elasticsearch/_async/http_aiohttp.py @@ -303,10 +303,9 @@ class AIOHttpConnection(AsyncConnection): raw_data = await response.text() duration = self.loop.time() - start - # We want to reraise a cancellation. - except asyncio.CancelledError: + # We want to reraise a cancellation or recursion error. + except (asyncio.CancelledError, RecursionError): raise - except Exception as e: self.log_request_fail( method, diff --git a/elasticsearch/connection/http_requests.py b/elasticsearch/connection/http_requests.py index 4480079f..84526d8d 100644 --- a/elasticsearch/connection/http_requests.py +++ b/elasticsearch/connection/http_requests.py @@ -166,6 +166,8 @@ class RequestsHttpConnection(Connection): response = self.session.send(prepared_request, **send_kwargs) duration = time.time() - start raw_data = response.content.decode("utf-8", "surrogatepass") + except RecursionError: + raise except Exception as e: self.log_request_fail( method, diff --git a/elasticsearch/connection/http_urllib3.py b/elasticsearch/connection/http_urllib3.py index 73a207d0..e343616d 100644 --- a/elasticsearch/connection/http_urllib3.py +++ b/elasticsearch/connection/http_urllib3.py @@ -253,6 +253,8 @@ class Urllib3HttpConnection(Connection): ) duration = time.time() - start raw_data = response.data.decode("utf-8", "surrogatepass") + except RecursionError: + raise except Exception as e: self.log_request_fail( method, full_url, url, orig_body, time.time() - start, exception=e