Skip to content

Commit fd31281

Browse files
author
zaihuaji
committed
stop db connections for error count exceeding limit
1 parent ca29f7d commit fd31281

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "rda_python_common"
7-
version = "2.0.10"
7+
version = "2.0.11"
88
authors = [
99
{ name="Zaihua Ji", email="zji@ucar.edu" },
1010
]

src/rda_python_common/PgDBI.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,8 @@ def check_dberror(pgerr, pgcnt, sqlstr, ary, logact = PGDBI['ERRLOG']):
468468

469469
if logact&PgLOG.DOLOCK and pgcode and re.match(r'^55\w\w\w$', pgcode):
470470
logact &= ~PgLOG.EXITLG # no exit for lock error
471+
elif pgcnt > PgLOG.PGLOG['DBRETRY']:
472+
logact |= PgLOG.EXITLG # exit for error count exceeds limit
471473
return qelog(dberror, 0, sqlstr, ary, pgcnt, logact)
472474

473475
#

src/rda_python_common/pg_dbi.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,8 @@ def check_dberror(self, pgerr, pgcnt, sqlstr, ary, logact = None):
366366
return self.SUCCESS
367367
if logact&self.DOLOCK and pgcode and re.match(r'^55\w\w\w$', pgcode):
368368
logact &= ~self.EXITLG # no exit for lock error
369+
elif pgcnt > self.PGLOG['DBRETRY']:
370+
logact |= self.EXITLG # exit for error count exceeds limit
369371
return self.qelog(dberror, 0, sqlstr, ary, pgcnt, logact)
370372

371373
# return hash reference to postgresql batch mode command and output file name

0 commit comments

Comments
 (0)