renamed tryCount local variable to try_count

This commit is contained in:
Dave Warnock 2012-06-11 15:11:53 +01:00
parent 913b0433f6
commit b9b0d83a00
1 changed files with 16 additions and 16 deletions

View File

@ -238,7 +238,7 @@ class Manager(object):
``commit`` ``commit``
Commit the session with this object Commit the session with this object
""" """
for tryCount in range(3): for try_count in range(3):
try: try:
self.session.add(object_instance) self.session.add(object_instance)
if commit: if commit:
@ -253,7 +253,7 @@ class Manager(object):
# way. So we only retry 3 times. # way. So we only retry 3 times.
log.exception(u'Probably a MySQL issue - "MySQL has gone away"') log.exception(u'Probably a MySQL issue - "MySQL has gone away"')
self.session.rollback() self.session.rollback()
if tryCount >= 2: if try_count >= 2:
raise raise
except InvalidRequestError: except InvalidRequestError:
self.session.rollback() self.session.rollback()
@ -273,7 +273,7 @@ class Manager(object):
``commit`` ``commit``
Commit the session with this object Commit the session with this object
""" """
for tryCount in range(3): for try_count in range(3):
try: try:
self.session.add_all(object_list) self.session.add_all(object_list)
if commit: if commit:
@ -288,7 +288,7 @@ class Manager(object):
# way. So we only retry 3 times. # way. So we only retry 3 times.
log.exception(u'Probably a MySQL issue, "MySQL has gone away"') log.exception(u'Probably a MySQL issue, "MySQL has gone away"')
self.session.rollback() self.session.rollback()
if tryCount >= 2: if try_count >= 2:
raise raise
except InvalidRequestError: except InvalidRequestError:
self.session.rollback() self.session.rollback()
@ -311,7 +311,7 @@ class Manager(object):
if not key: if not key:
return object_class() return object_class()
else: else:
for tryCount in range(3): for try_count in range(3):
try: try:
return self.session.query(object_class).get(key) return self.session.query(object_class).get(key)
except OperationalError: except OperationalError:
@ -321,7 +321,7 @@ class Manager(object):
# However, other dbms can raise it, usually in a non-recoverable # However, other dbms can raise it, usually in a non-recoverable
# way. So we only retry 3 times. # way. So we only retry 3 times.
log.exception(u'Probably a MySQL issue, "MySQL has gone away"') log.exception(u'Probably a MySQL issue, "MySQL has gone away"')
if tryCount >= 2: if try_count >= 2:
raise raise
def get_object_filtered(self, object_class, filter_clause): def get_object_filtered(self, object_class, filter_clause):
@ -334,7 +334,7 @@ class Manager(object):
``filter_clause`` ``filter_clause``
The criteria to select the object by The criteria to select the object by
""" """
for tryCount in range(3): for try_count in range(3):
try: try:
return self.session.query(object_class).filter(filter_clause).first() return self.session.query(object_class).filter(filter_clause).first()
except OperationalError: except OperationalError:
@ -344,7 +344,7 @@ class Manager(object):
# However, other dbms can raise it, usually in a non-recoverable # However, other dbms can raise it, usually in a non-recoverable
# way. So we only retry 3 times. # way. So we only retry 3 times.
log.exception(u'Probably a MySQL issue, "MySQL has gone away"') log.exception(u'Probably a MySQL issue, "MySQL has gone away"')
if tryCount >= 2: if try_count >= 2:
raise raise
def get_all_objects(self, object_class, filter_clause=None, def get_all_objects(self, object_class, filter_clause=None,
@ -369,7 +369,7 @@ class Manager(object):
query = query.order_by(*order_by_ref) query = query.order_by(*order_by_ref)
elif order_by_ref is not None: elif order_by_ref is not None:
query = query.order_by(order_by_ref) query = query.order_by(order_by_ref)
for tryCount in range(3): for try_count in range(3):
try: try:
return query.all() return query.all()
except OperationalError: except OperationalError:
@ -379,7 +379,7 @@ class Manager(object):
# However, other dbms can raise it, usually in a non-recoverable # However, other dbms can raise it, usually in a non-recoverable
# way. So we only retry 3 times. # way. So we only retry 3 times.
log.exception(u'Probably a MySQL issue, "MySQL has gone away"') log.exception(u'Probably a MySQL issue, "MySQL has gone away"')
if tryCount >= 2: if try_count >= 2:
raise raise
def get_object_count(self, object_class, filter_clause=None): def get_object_count(self, object_class, filter_clause=None):
@ -396,7 +396,7 @@ class Manager(object):
query = self.session.query(object_class) query = self.session.query(object_class)
if filter_clause is not None: if filter_clause is not None:
query = query.filter(filter_clause) query = query.filter(filter_clause)
for tryCount in range(3): for try_count in range(3):
try: try:
return query.count() return query.count()
except OperationalError: except OperationalError:
@ -406,7 +406,7 @@ class Manager(object):
# However, other dbms can raise it, usually in a non-recoverable # However, other dbms can raise it, usually in a non-recoverable
# way. So we only retry 3 times. # way. So we only retry 3 times.
log.exception(u'Probably a MySQL issue, "MySQL has gone away"') log.exception(u'Probably a MySQL issue, "MySQL has gone away"')
if tryCount >= 2: if try_count >= 2:
raise raise
def delete_object(self, object_class, key): def delete_object(self, object_class, key):
@ -421,7 +421,7 @@ class Manager(object):
""" """
if key != 0: if key != 0:
object_instance = self.get_object(object_class, key) object_instance = self.get_object(object_class, key)
for tryCount in range(3): for try_count in range(3):
try: try:
self.session.delete(object_instance) self.session.delete(object_instance)
self.session.commit() self.session.commit()
@ -435,7 +435,7 @@ class Manager(object):
# way. So we only retry 3 times. # way. So we only retry 3 times.
log.exception(u'Probably a MySQL issue, "MySQL has gone away"') log.exception(u'Probably a MySQL issue, "MySQL has gone away"')
self.session.rollback() self.session.rollback()
if tryCount >= 2: if try_count >= 2:
raise raise
except InvalidRequestError: except InvalidRequestError:
self.session.rollback() self.session.rollback()
@ -461,7 +461,7 @@ class Manager(object):
The filter governing selection of objects to return. Defaults to The filter governing selection of objects to return. Defaults to
None. None.
""" """
for tryCount in range(3): for try_count in range(3):
try: try:
query = self.session.query(object_class) query = self.session.query(object_class)
if filter_clause is not None: if filter_clause is not None:
@ -478,7 +478,7 @@ class Manager(object):
# way. So we only retry 3 times. # way. So we only retry 3 times.
log.exception(u'Probably a MySQL issue, "MySQL has gone away"') log.exception(u'Probably a MySQL issue, "MySQL has gone away"')
self.session.rollback() self.session.rollback()
if tryCount >= 2: if try_count >= 2:
raise raise
except InvalidRequestError: except InvalidRequestError:
self.session.rollback() self.session.rollback()