Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

keep track of number of calls #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
11 changes: 9 additions & 2 deletions pybase/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -38,6 +39,8 @@

logger = logging.getLogger(__name__)

max_recursion_depth = sys.getrecursionlimit()


class MainClient(object):

Expand Down Expand Up @@ -146,14 +149,15 @@ 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
:param key: row key
: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:
Expand All @@ -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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

an exception description could help find this later:

                raise Exception("hbase get recursion call limit reached")

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)
Expand Down