Merge lp:~sidnei/storm/disconnection-send-data into lp:storm

Proposed by Sidnei da Silva
Status: Merged
Approved by: Jamu Kakar
Approved revision: 465
Merged at revision: 466
Proposed branch: lp:~sidnei/storm/disconnection-send-data
Merge into: lp:storm
Diff against target: 56 lines (+21/-2)
2 files modified
storm/databases/postgres.py (+1/-0)
tests/databases/postgres.py (+20/-2)
To merge this branch: bzr merge lp:~sidnei/storm/disconnection-send-data
Reviewer Review Type Date Requested Status
Free Ekanayaka (community) Approve
Jamu Kakar (community) Approve
Review via email: mp+187617@code.launchpad.net

Commit message

Treat 'could not send data to server' as a DisconnectionError too.

Description of the change

Treat 'could not send data to server' as a DisconnectionError too.

To post a comment you must log in.
Revision history for this message
Jamu Kakar (jkakar) wrote :

Nice one, +1!

review: Approve
Revision history for this message
Free Ekanayaka (free.ekanayaka) wrote :

Looks good, thanks for adding the additional test. +1!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'storm/databases/postgres.py'
2--- storm/databases/postgres.py 2012-04-04 23:44:02 +0000
3+++ storm/databases/postgres.py 2013-09-25 22:08:29 +0000
4@@ -322,6 +322,7 @@
5 "connection not open" in msg or
6 "could not connect to server" in msg or
7 "could not receive data from server" in msg or
8+ "could not send data to server" in msg or
9 "losed the connection unexpectedly" in msg or
10 "no connection to the server" in msg or
11 "server closed the connection unexpectedly" in msg or
12
13=== modified file 'tests/databases/postgres.py'
14--- tests/databases/postgres.py 2012-06-12 10:00:51 +0000
15+++ tests/databases/postgres.py 2013-09-25 22:08:29 +0000
16@@ -28,7 +28,7 @@
17 from storm.variables import DateTimeVariable, RawStrVariable
18 from storm.variables import ListVariable, IntVariable, Variable
19 from storm.properties import Int
20-from storm.exceptions import DisconnectionError
21+from storm.exceptions import DisconnectionError, OperationalError
22 from storm.expr import (Union, Select, Insert, Update, Alias, SQLRaw, State,
23 Sequence, Like, Column, COLUMN)
24 from storm.tracer import install_tracer, TimeoutError
25@@ -579,12 +579,30 @@
26 exc = ProgrammingError("SSL SYSCALL error: Connection timed out")
27 self.assertTrue(self.connection.is_disconnection_error(exc))
28
29+ def test_is_disconnection_error_with_could_not_send_data(self):
30+ """
31+ If the underlying driver raises an OperationalError with 'could not
32+ send data to server', we consider the connection
33+ dead and mark it as needing reconnection.
34+ """
35+ exc = OperationalError("could not send data to server")
36+ self.assertTrue(self.connection.is_disconnection_error(exc))
37+
38+ def test_is_disconnection_error_with_could_not_receive_data(self):
39+ """
40+ If the underlying driver raises an OperationalError with 'could not
41+ receive data from server', we consider the connection
42+ dead and mark it as needing reconnection.
43+ """
44+ exc = OperationalError("could not receive data from server")
45+ self.assertTrue(self.connection.is_disconnection_error(exc))
46+
47
48 _max_prepared_transactions = None
49
50
51 class PostgresTwoPhaseCommitTest(TwoPhaseCommitTest, TestHelper):
52-
53+
54 def is_supported(self):
55 uri = os.environ.get("STORM_POSTGRES_URI")
56 if not uri:

Subscribers

People subscribed via source and target branches

to status/vote changes: