コード例 #1
0
ファイル: decorators.py プロジェクト: disqus/disqus-postgres
    def inner(self, *args, **kwargs):
        try:
            return func(self, *args, **kwargs)
        except Exception, e:
            if not can_reconnect(e):
                raise

            self.close(reconnect=True)

            return func(self, *args, **kwargs)
コード例 #2
0
    def inner(self, *args, **kwargs):
        try:
            return func(self, *args, **kwargs)
        except Exception, e:
            if not can_reconnect(e):
                raise

            self.close(reconnect=True)

            return func(self, *args, **kwargs)
コード例 #3
0
ファイル: tests.py プロジェクト: valsteen/disqus-postgres
 def test_can_reconnect_on_interface_error(self):
     exc = psycopg2.InterfaceError("herp derp")
     assert can_reconnect(exc) is True
コード例 #4
0
ファイル: tests.py プロジェクト: valsteen/disqus-postgres
 def test_cannot_reconnect_on_generic_error(self):
     exc = DatabaseError("foo bar")
     assert can_reconnect(exc) is False
コード例 #5
0
ファイル: tests.py プロジェクト: valsteen/disqus-postgres
 def test_can_reconnect_on_client_idle_timeout_error(self):
     exc = DatabaseError("client_idle_timeout")
     assert can_reconnect(exc) is True
コード例 #6
0
ファイル: tests.py プロジェクト: valsteen/disqus-postgres
 def test_can_reconnect_on_closed_connection_error(self):
     exc = DatabaseError("server closed the connection unexpectedly")
     assert can_reconnect(exc) is True
コード例 #7
0
ファイル: tests.py プロジェクト: valsteen/disqus-postgres
 def test_can_reconnect_on_datestyle_error(self):
     exc = psycopg2.OperationalError("can't set datestyle to ISO")
     assert can_reconnect(exc) is True
コード例 #8
0
ファイル: tests.py プロジェクト: valsteen/disqus-postgres
 def test_can_reconnect_on_default_isolation_level_error(self):
     exc = psycopg2.OperationalError("can't fetch default_isolation_level")
     assert can_reconnect(exc) is True
コード例 #9
0
 def test_can_reconnect_on_interface_error(self):
     exc = psycopg2.InterfaceError('herp derp')
     assert can_reconnect(exc) is True
コード例 #10
0
 def test_cannot_reconnect_on_generic_error(self):
     exc = DatabaseError("foo bar")
     assert can_reconnect(exc) is False
コード例 #11
0
 def test_can_reconnect_on_client_idle_timeout_error(self):
     exc = DatabaseError("client_idle_timeout")
     assert can_reconnect(exc) is True
コード例 #12
0
 def test_can_reconnect_on_closed_connection_error(self):
     exc = DatabaseError("server closed the connection unexpectedly")
     assert can_reconnect(exc) is True
コード例 #13
0
 def test_can_reconnect_on_datestyle_error(self):
     exc = psycopg2.OperationalError("can't set datestyle to ISO")
     assert can_reconnect(exc) is True
コード例 #14
0
 def test_can_reconnect_on_default_isolation_level_error(self):
     exc = psycopg2.OperationalError("can't fetch default_isolation_level")
     assert can_reconnect(exc) is True