Skip to content

Commit 9183c91

Browse files
author
Richard Jones
committed
better conflict retry in postgresql backend [SF#1552809]
fix time log example [SF#1554630]
1 parent e4b6821 commit 9183c91

File tree

4 files changed

+22
-7
lines changed

4 files changed

+22
-7
lines changed

CHANGES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ Fixed:
5555
in classic template (sf patch 1424576)
5656
- "as" is a keyword in Python 2.6
5757
- "from __future__" statments need to be first line of file in Python 2.6
58+
- better conflict retry in postgresql backend (sf bug 1552809)
59+
- fix time log example (sf bug 1554630)
5860

5961

6062
2006-04-27 1.1.2

doc/customizing.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Customising Roundup
33
===================
44

5-
:Version: $Revision: 1.207 $
5+
:Version: $Revision: 1.208 $
66

77
.. This document borrows from the ZopeBook section on ZPT. The original is at:
88
http://www.zope.org/Documentation/Books/ZopeBook/current/ZPT.stx
@@ -3373,11 +3373,13 @@ be able to give a summary of the total time spent on a particular issue.
33733373
to the ``extensions`` directory in our tracker. The contents of this
33743374
file is as follows::
33753375

3376+
from roundup import date
3377+
33763378
def totalTimeSpent(times):
33773379
''' Call me with a list of timelog items (which have an
33783380
Interval "period" property)
33793381
'''
3380-
total = Interval('0d')
3382+
total = date.Interval('0d')
33813383
for time in times:
33823384
total += time.period._value
33833385
return total

doc/index.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ letting me implement this system on their time.
6363
Thanks also to the many people on the mailing list, in the sourceforge
6464
project and those who just report bugs:
6565
Thomas Arendsen Hein,
66+
Nerijus Baliunas,
6667
Anthony Baxter,
6768
Marlon van den Berg,
6869
Bo Berglund,

roundup/backends/back_postgresql.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#$Id: back_postgresql.py,v 1.35 2006-10-03 23:15:09 richard Exp $
1+
#$Id: back_postgresql.py,v 1.36 2006-10-03 23:28:51 richard Exp $
22
#
33
# Copyright (c) 2003 Martynas Sklyzmantas, Andrey Lebedev <[email protected]>
44
#
@@ -70,6 +70,8 @@ def db_command(config, command):
7070
def pg_command(cursor, command):
7171
'''Execute the postgresql command, which may be blocked by some other
7272
user connecting to the database, and return a true value if it succeeds.
73+
74+
If there is a concurrent update, retry the command.
7375
'''
7476
try:
7577
cursor.execute(command)
@@ -78,10 +80,18 @@ def pg_command(cursor, command):
7880
if response.find('FATAL') != -1:
7981
raise RuntimeError, response
8082
elif response.find('ERROR') != -1:
81-
if response.find('is being accessed by other users') == -1:
82-
raise RuntimeError, response
83-
time.sleep(1)
84-
return 0
83+
msgs = [
84+
'is being accessed by other users',
85+
'could not serialize access due to concurrent update',
86+
]
87+
can_retry = 0
88+
for msg in msgs:
89+
if response.find(msg) == -1:
90+
can_retry = 1
91+
if can_retry:
92+
time.sleep(1)
93+
return 0
94+
raise RuntimeError, response
8595
return 1
8696

8797
def db_exists(config):

0 commit comments

Comments
 (0)