Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Give the ability to pass arguments to the backend #40

merged 1 commit into from Jan 11, 2013


None yet
2 participants

ahassany commented Jan 31, 2012

The current backend interface doesn't have anyway for the user to pass arguments to it. At least in the tornado backend, sometime it's needed to pass the IOLoop instance to the IOStream.

For example:

from tornado.testing import AsyncTestCase
import asyncmongo

class AsyncTest(AsyncTestCase):
    def test_insert(self):
        db = asyncmongo.Client(pool_id='testinsert', host='', port=27017, dbname='test')
        db.test_users.insert({"one" : 1}, callback=self.insert_callback)

    def insert_callback(self, response, error=None):
        self.assertEqual(1, 1)

will hang forever because IOStream created another IOLoop instance different from the unittest IOLoop instance.

But with this update, it can be fixed by connecting using

db = asyncmongo.Client(pool_id='testinsert', host='', port=27017, dbname='test', io_loop=self.io_loop)

BTW, I have not test this with GLib backend.

@jehiah jehiah added a commit that referenced this pull request Jan 11, 2013

@jehiah jehiah Merge pull request #40 from ahassany/master
Give the ability to pass arguments to the backend

@jehiah jehiah merged commit 6be100e into bitly:master Jan 11, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment