From cb9000c8ea64dacd59177a4cfbb7fc6016ce537e Mon Sep 17 00:00:00 2001 From: Sojin Lim Date: Fri, 16 Jun 2023 16:00:07 -0400 Subject: [PATCH] keep track of number of calls --- pybase/client.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pybase/client.py b/pybase/client.py index 3dfa029..2513b4b 100644 --- a/pybase/client.py +++ b/pybase/client.py @@ -18,6 +18,7 @@ import logging from builtins import str from itertools import chain +import sys from threading import Condition, Lock import pybase.region.client as region @@ -38,6 +39,8 @@ logger = logging.getLogger(__name__) +max_recursion_depth = sys.getrecursionlimit() + class MainClient(object): @@ -146,7 +149,7 @@ def _delete_from_region_cache(self, table, start_key): HERE LAY REQUESTS """ - def get(self, table, key, families={}, filters=None): + def get(self, table, key, families={}, filters=None, call_number=0): """ get a row or specified cell with optional filter :param table: hbase table @@ -154,6 +157,7 @@ def get(self, table, key, families={}, filters=None): :param families: (optional) specifies columns to get, e.g., {"columnFamily1":["col1","col2"], "colFamily2": "col3"} :param filters: (optional) column filters + :param call_number: (optional) count of recursion stack :return: response with cells """ try: @@ -180,7 +184,10 @@ def get(self, table, key, families={}, filters=None): # which region or region_client it needs to reestablish. e._handle_exception(self, dest_region=dest_region) # Everything should be dandy now. Repeat the request! - return self.get(table, key, families=families, filters=filters) + call_number += 1 + if call_number > max_recursion_depth: + raise Exception + return self.get(table, key, families=families, filters=filters, call_number=call_number) def put(self, table, key, values): return self._mutate(table, key, values, request.put_request)