Skip to content
This repository has been archived by the owner on Sep 24, 2022. It is now read-only.

Catching ALL types of early error. Fixes #79. #80

Merged
merged 1 commit into from
Nov 16, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion momoko/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ def wrapper(self, *args, **kwargs):
callback = kwargs.get("callback", _dummy_callback)
try:
return func(self, *args, **kwargs)
except psycopg2.Error as error:
except Exception as error:
callback(None, error)
return wrapper

Expand Down
10 changes: 10 additions & 0 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,16 @@ def func():

self.assert_raises(psycopg2.ProgrammingError, self.run_gen, func)

def test_op_early_exception(self):
"""Testing that Op propagates early exceptions properly"""
@gen.engine
def func():
cursor = yield momoko.Op(self.db.execute, 'SELECT %s FROM %s', ())
self.stop()

self.assert_raises(IndexError, self.run_gen, func)
self.assertFalse(self.db._conns.busy, msg="Busy connction was not returned to pool after exception")

def test_wait_op(self):
"""Testing WaitOp"""
@gen.engine
Expand Down