Skip to content
Browse files

Small cleanup.

  • Loading branch information...
1 parent d63248b commit 20d8e3570219b8dcf0e913277b6cd937af7bbe16 @FSX committed Jan 16, 2012
Showing with 8 additions and 13 deletions.
  1. +8 −10 momoko/pools.py
  2. +0 −3 momoko/utils.py
View
18 momoko/pools.py
@@ -178,9 +178,9 @@ def _new_conn(self, new_cursor_args={}):
if new_cursor_args:
new_cursor_args['connection'] = conn
new_cursor = functools.partial(self.new_cursor, **new_cursor_args)
- Poller(conn, (add_conn, new_cursor), ioloop=self._ioloop).start()
+ Poller(conn, (add_conn, new_cursor), ioloop=self._ioloop)
else:
- Poller(conn, (add_conn,), ioloop=self._ioloop).start()
+ Poller(conn, (add_conn,), ioloop=self._ioloop)
def _add_conn(self, conn):
"""Add a connection to the pool.
@@ -205,12 +205,11 @@ def new_cursor(self, function, func_args=(), callback=None, connection=None):
if not connection:
connection = self._get_free_conn()
if not connection:
- new_cursor_args = {
+ self._new_conn({
'function': function,
'func_args': func_args,
'callback': callback
- }
- self._new_conn(new_cursor_args)
+ })
return
try:
@@ -219,19 +218,18 @@ def new_cursor(self, function, func_args=(), callback=None, connection=None):
# Callbacks from cursor functions always get the cursor back
if callback:
- cb = functools.partial(callback, cursor)
- Poller(cursor.connection, (cb,), ioloop=self._ioloop).start()
+ Poller(cursor.connection, (functools.partial(callback, cursor),),
+ ioloop=self._ioloop)
except (DatabaseError, InterfaceError):
logging.warning('Requested connection was closed')
self._pool.remove(connection)
connection = self._get_free_conn()
if not connection:
- new_cursor_args = {
+ self._new_conn({
'function': function,
'func_args': func_args,
'callback': callback
- }
- self._new_conn(new_cursor_args)
+ })
else:
self.new_cursor(function, func_args, callback, connection)
View
3 momoko/utils.py
@@ -119,9 +119,6 @@ def __init__(self, connection, callbacks=(), ioloop=None):
self._connection = connection
self._callbacks = callbacks
- def start(self):
- """Start polling the connection.
- """
self._update_handler()
def _update_handler(self):

0 comments on commit 20d8e35

Please sign in to comment.
Something went wrong with that request. Please try again.