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
=== modified file 'storm/databases/postgres.py'
--- storm/databases/postgres.py 2012-04-04 23:44:02 +0000
+++ storm/databases/postgres.py 2013-09-25 22:08:29 +0000
@@ -322,6 +322,7 @@
322 "connection not open" in msg or322 "connection not open" in msg or
323 "could not connect to server" in msg or323 "could not connect to server" in msg or
324 "could not receive data from server" in msg or324 "could not receive data from server" in msg or
325 "could not send data to server" in msg or
325 "losed the connection unexpectedly" in msg or326 "losed the connection unexpectedly" in msg or
326 "no connection to the server" in msg or327 "no connection to the server" in msg or
327 "server closed the connection unexpectedly" in msg or328 "server closed the connection unexpectedly" in msg or
328329
=== modified file 'tests/databases/postgres.py'
--- tests/databases/postgres.py 2012-06-12 10:00:51 +0000
+++ tests/databases/postgres.py 2013-09-25 22:08:29 +0000
@@ -28,7 +28,7 @@
28from storm.variables import DateTimeVariable, RawStrVariable28from storm.variables import DateTimeVariable, RawStrVariable
29from storm.variables import ListVariable, IntVariable, Variable29from storm.variables import ListVariable, IntVariable, Variable
30from storm.properties import Int30from storm.properties import Int
31from storm.exceptions import DisconnectionError31from storm.exceptions import DisconnectionError, OperationalError
32from storm.expr import (Union, Select, Insert, Update, Alias, SQLRaw, State,32from storm.expr import (Union, Select, Insert, Update, Alias, SQLRaw, State,
33 Sequence, Like, Column, COLUMN)33 Sequence, Like, Column, COLUMN)
34from storm.tracer import install_tracer, TimeoutError34from storm.tracer import install_tracer, TimeoutError
@@ -579,12 +579,30 @@
579 exc = ProgrammingError("SSL SYSCALL error: Connection timed out")579 exc = ProgrammingError("SSL SYSCALL error: Connection timed out")
580 self.assertTrue(self.connection.is_disconnection_error(exc))580 self.assertTrue(self.connection.is_disconnection_error(exc))
581581
582 def test_is_disconnection_error_with_could_not_send_data(self):
583 """
584 If the underlying driver raises an OperationalError with 'could not
585 send data to server', we consider the connection
586 dead and mark it as needing reconnection.
587 """
588 exc = OperationalError("could not send data to server")
589 self.assertTrue(self.connection.is_disconnection_error(exc))
590
591 def test_is_disconnection_error_with_could_not_receive_data(self):
592 """
593 If the underlying driver raises an OperationalError with 'could not
594 receive data from server', we consider the connection
595 dead and mark it as needing reconnection.
596 """
597 exc = OperationalError("could not receive data from server")
598 self.assertTrue(self.connection.is_disconnection_error(exc))
599
582600
583_max_prepared_transactions = None601_max_prepared_transactions = None
584602
585603
586class PostgresTwoPhaseCommitTest(TwoPhaseCommitTest, TestHelper):604class PostgresTwoPhaseCommitTest(TwoPhaseCommitTest, TestHelper):
587 605
588 def is_supported(self):606 def is_supported(self):
589 uri = os.environ.get("STORM_POSTGRES_URI")607 uri = os.environ.get("STORM_POSTGRES_URI")
590 if not uri:608 if not uri:

Subscribers

People subscribed via source and target branches

to status/vote changes: