Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added checks for callbacks.

  • Loading branch information...
commit 4f1f40450a1903db9dc5074bfdee527c24639fd7 1 parent d7f83fe
Frank Smit authored
Showing with 8 additions and 4 deletions.
  1. +8 −3 momoko/connection.py
  2. +0 −1  momoko/utils.py
11 momoko/connection.py
View
@@ -185,7 +185,9 @@ def __init__(self,
self._transaction_status = self.connection.get_transaction_status
self.ioloop = ioloop or IOLoop.instance()
- self.callback = partial(callback, self)
+ if callback:
+ self.callback = partial(callback, self)
+
self.ioloop.add_handler(self.fileno, self.io_callback, IOLoop.WRITE)
def io_callback(self, fd=None, events=None):
@@ -197,11 +199,14 @@ def io_callback(self, fd=None, events=None):
if not isinstance(error, psycopg2.DatabaseError):
self.ioloop.update_handler(self.fileno, 0)
- self.callback(error)
+ if self.callback:
+ self.callback(error)
else:
if state == POLL_OK:
self.ioloop.update_handler(self.fileno, 0)
- self.callback(None)
+
+ if self.callback:
+ self.callback(None)
elif state == POLL_READ:
self.ioloop.update_handler(self.fileno, IOLoop.READ)
elif state == POLL_WRITE:
1  momoko/utils.py
View
@@ -9,7 +9,6 @@
MIT, see LICENSE for more details.
"""
-
import sys
from tornado import gen
from functools import partial
Please sign in to comment.
Something went wrong with that request. Please try again.