profile
viewpoint
If you are wondering where the data of this site comes from, please visit https://api.github.com/users/ankurchavda/events. GitMemory does not store any data, but only uses NGINX to cache data for a period of time. The idea behind GitMemory is simply to give users a better reading experience.
tremoloplusdelay ankurchavda Data Engineer. Spark. Python

ankurchavda/SparkLearning 411

A comprehensive Spark guide collated from multiple sources that can be referred to learn more about Spark or as an interview refresher.

ankurchavda/awesome-interview-questions 1

:octocat: A curated awesome list of lists of interview questions. Feel free to contribute! :mortar_board:

ankurchavda/SparkStreamingWithTwitter 1

Consuming tweets from a local port into spark using streaming API

ankurchavda/Taming-Bigdata---Pyspark 1

All the code examples from the course that I completed on Udemy -- Taming Bigdata Using Spark and Python

ankurchavda/ankurchavda 0

Config files for my GitHub profile.

ankurchavda/email-scheduler 0

A email scheduler that pulls list of emails from the database and sends campaigns using mailjet api on a specified recurrence rule.

ankurchavda/Endpoints 0

JWT, json patching and thumbnail creation end points

ankurchavda/Footy-Info 0

A react-app to get you roster of European football clubs

ankurchavda/LogAnalyzer 0

A basic log analyzer created to analyze logs from Apache web servers.

issue commentcouchbase/docs-sdk-python

Is Error Handling example upto date?

Hi @thejcfactor - I used the base exception CouchbaseException for couchbase_connect function -

@allow_retries(backoff=0.5, exponential_backoff=True, allowed_exceptions=(CouchbaseException))

The allow_retries did not seem to catch AuthenticationException, TimeoutException.

I was expecting that since CouchbaseException is the base class, if allowed_exceptions is None or not isinstance(err, allowed_exceptions): would consider AuthenticationException an instance of CouchbaseException type. My understanding might be incorrect and sorry for digressing and asking a python related question. But will I have to catch and retry the exact exceptions using this decorator?

ankurchavda

comment created time in 4 days

issue commentcouchbase/docs-sdk-python

Is Error Handling example upto date?

Hi @thejcfactor, Sadly can't use SDK Doctor for the time being. But the code that you shared is very helpful, have added this decorator in my code for retrying after exceptions. Will let you know how the retry robustness changes after using this but the code definitely has become cleaner. Thanks.

ankurchavda

comment created time in 8 days

issue commentcouchbase/docs-sdk-python

Is Error Handling example upto date?

Hi @thejcfactor - The Authentication exception came in despite the credentials being correct. Also, it was resolved on a retry, but I have to specifically catch via AuthenticationException and retry there. Also on this retry, another exception was thrown LCB_ERROR_UNKNOWN_HOST. And the issue is that none of them are caught under CouchbaseTransientException which is causing the program to fail. Is there is a more robust way to handle these kind of errors that can be resolved via retries?

Also, it would great if you can share the sample of what you are trying to suggest. image

ankurchavda

comment created time in 10 days

issue commentcouchbase/docs-sdk-python

Is Error Handling example upto date?

Sure that would be great, thank you!

ankurchavda

comment created time in 11 days

issue commentcouchbase/docs-sdk-python

Is Error Handling example upto date?

Thanks for the quick action @osfameron. I am trying to add proper error handling to my code. Can you please check if the below code looks good?

def couchbase_connection(username, password, host, bucket='bucketname', max_retries=5, back_off=0.1):
    """
    Create couchbase connection

        Parameters:
            username: user id
            password: password
            host: connection string
            bucket (string): Name of the couchbase bucket
            max_retries (int): An integer
            back_off (int): An integer

        Returns:
            collection (couchbase.collections): A couchbase collection object

    """
    try:
        log.info("Creating couchbase connection.")
        # Setting timeout options for cluster object. kv_timeout is for key-value operations
        # like get() and other mutation commands. Simlarly query_timeout is for N1QL queries.
        options = ClusterTimeoutOptions(kv_timeout=timedelta(
            seconds=60), query_timeout=timedelta(seconds=120))

        cluster = Cluster('couchbase://' + host, ClusterOptions(
            PasswordAuthenticator(username, password), timeout_options=options))

        bucket = cluster.bucket('matrixDB')
        collection = bucket.default_collection()
        log.info("Connection created.")
        return collection

    # Transient errors are something that resolve automatically. is_retyable is provided
    # for such errors. So have added a retry mechanism if the error is retryable.
    except couchbase_exceptions.CouchbaseTransientException as err:
        log.error(f"Encountered a transient error: {err}")
        if max_retries > 0:
            log.info(f"Retries left: {max_retries}")
            log.info(f"Backing Off: {back_off} seconds")
            sleep(back_off)
            couchbase_connection(username, password, bucket,
                                 max_retries=max_retries-1, back_off=back_off*2)
        else:
            log.error(
                f"Too many attempts to create connection with couchbase: {err}")
            raise
    # catch generic couchbase exception
    except couchbase_exceptions.CouchbaseException as err:
        log.error(f"Unexpected error {err}")

So I have written the above function to create a couchbase connection. I catch transient errors and retry couchbase creation there. So should I also add is_transient check under CouchbaseException? Because sometimes connection creation fails with LCB_ERR_AUTHENTICATION_FAILURE (206) and that is not caught under CouchbaseTransientException.

ankurchavda

comment created time in 11 days

issue commentcouchbase/docs-sdk-python

Is Error Handling example upto date?

@osfameron The one on the official website - https://docs.couchbase.com/python-sdk/current/howtos/error-handling.html.

And the guthub code for this is https://github.com/couchbase/docs-sdk-python/blob/a1bd25c85d8480f47ab67d58da789643dfb58f1c/modules/howtos/examples/error-handling.py#L154-L198

ankurchavda

comment created time in 12 days

push eventankurchavda/ankurchavda.github.io

tremoloplusdelay

commit sha 0a19b76e2c183986be12bdfedf18c497b069069c

break tag

view details

push time in a month

push eventankurchavda/ankurchavda.github.io

tremoloplusdelay

commit sha 1d9061fdd68f632c492abb4546d3e372128007f4

Bio enhanced

view details

push time in a month

push eventankurchavda/ankurchavda.github.io

tremoloplusdelay

commit sha 4511176805dbea1eecaf6d6868587c9c5763700e

title addition

view details

push time in 2 months

push eventankurchavda/ankurchavda.github.io

tremoloplusdelay

commit sha 009852017ff048319dcf84753eecc217ec4a091c

site title

view details

push time in 2 months

push eventankurchavda/ankurchavda.github.io

tremoloplusdelay

commit sha 6501faed24df03f2743e772797068547d0894f1b

favicon & social links

view details

tremoloplusdelay

commit sha 7d937f0d73e60dd717ba7b7b8bcb2ceb9adcb40f

favicon files

view details

push time in 2 months

push eventankurchavda/ankurchavda.github.io

tremoloplusdelay

commit sha ef1c43cbbb9b840a210e29e5cab96d120742eb2f

width change

view details

tremoloplusdelay

commit sha a042ea6838cff992de933307eaa6f521ee718f0d

Merge branch 'main' of https://github.com/ankurchavda/tremoloplusdelay.github.io into main

view details

push time in 2 months

MemberEvent

push eventankurchavda/ankurchavda.github.io

tremoloplusdelay

commit sha 3be8cb161bd193d48bb4cfd69cc907fc149b0470

image resize

view details

tremoloplusdelay

commit sha c71b9cef73244d0a5c72a7995547b921284d507a

Merge branch 'main' of https://github.com/ankurchavda/tremoloplusdelay.github.io into main

view details

push time in 2 months

push eventankurchavda/ankurchavda.github.io

tremoloplusdelay

commit sha d2121fde6995e564d8e9a7f0d638661382ee395b

Set theme jekyll-theme-cayman

view details

push time in 2 months

push eventankurchavda/ankurchavda.github.io

tremoloplusdelay

commit sha fab389c8e4a285c62cae09dd0bc47c2f5f1f9c32

Delete CNAME

view details

push time in 2 months

push eventankurchavda/ankurchavda.github.io

tremoloplusdelay

commit sha 9d87a22a412a37ae6c34f5ec0e818e6c10700842

Create CNAME

view details

push time in 2 months

push eventankurchavda/ankurchavda.github.io

tremoloplusdelay

commit sha 392b17020bc60b61dd02227822fd7aec791773fc

change layout

view details

push time in 2 months

create barnchankurchavda/tremoloplusdelay.github.io

branch : main

created branch time in 2 months

created repositoryankurchavda/tremoloplusdelay.github.io

EPK

created time in 2 months