Skip to content
This repository has been archived by the owner on Aug 25, 2023. It is now read-only.

Commit

Permalink
YACHT-997: Changed exception handling from Error to DeadlineExceededE…
Browse files Browse the repository at this point in the history
…rror
  • Loading branch information
przemyslaw-jasinski committed Sep 19, 2018
1 parent 669ee01 commit 1a2484b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/backup/datastore/Table.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import logging

from datetime import timedelta, date
from google.appengine.api.urlfetch_errors import DeadlineExceededError
from google.appengine.ext import ndb

from src.backup.datastore.Backup import Backup
Expand All @@ -16,7 +17,7 @@ class Table(ndb.Model):
partition_id = ndb.StringProperty(indexed=True)

@classmethod
@retry(Exception, tries=5, delay=1, backoff=2)
@retry(DeadlineExceededError, tries=5, delay=1, backoff=2)
def create(cls, project_id, dataset_id, table_id,
partition_id, last_checked):

Expand All @@ -32,7 +33,7 @@ def create(cls, project_id, dataset_id, table_id,
)
table_entity.put()

@retry(Exception, tries=5, delay=1, backoff=2)
@retry(DeadlineExceededError, tries=5, delay=1, backoff=2)
def update_last_check(self, last_checked):
table_reference = TableReference(self.project_id, self.dataset_id,
self.table_id, self.partition_id)
Expand Down
7 changes: 4 additions & 3 deletions src/commons/big_query/big_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
import googleapiclient.discovery
import httplib2
from apiclient.errors import HttpError, Error
from google.appengine.api.urlfetch_errors import DeadlineExceededError
from oauth2client.client import GoogleCredentials

from src.commons.big_query.big_query_table import BigQueryTable
from src.commons.config.configuration import configuration
from src.commons.decorators.cached import cached
from src.commons.decorators.google_http_error_retry import \
google_http_error_retry
from src.commons.decorators.log_time import log_time, measure_time_and_log
from src.commons.decorators.retry import retry
from src.commons.big_query.big_query_table import BigQueryTable
from src.commons.config.configuration import configuration
from src.commons.table_reference import TableReference


Expand Down Expand Up @@ -124,7 +125,7 @@ def execute_query(self, query, use_legacy_sql=True):
return results

@log_time
@retry(Error, tries=5, delay=1, backoff=2)
@retry(DeadlineExceededError, tries=5, delay=1, backoff=2)
def list_table_partitions(self, project_id, dataset_id, table_id):
results = self.execute_query(
self.create_partition_query(project_id, dataset_id, table_id))
Expand Down

0 comments on commit 1a2484b

Please sign in to comment.