Waiting for multiple dbs using Consumer object

14 views
Skip to first unread message

Fabio Di Bernardini

unread,
Dec 6, 2011, 6:32:24 AM12/6/11
to couch...@googlegroups.com
Hi all

I need to wait for changes from multiple dbs, but using the Consumer class with callbacks, I noticed the lack of a non blocking wait.

What's the best method to wait for multiple databases?

Thanks.

Benoit Chesneau

unread,
Dec 6, 2011, 7:27:37 AM12/6/11
to couch...@googlegroups.com
> --
>

You can use an eventlet or gevent consumer with the wait_async
method. Then the callback will be handled asynchronously.


from couchdbkit.consumer import Consumer

c = Consumer(db, backend='gevent')
c.wait_async(cb, **changes_params)


- benoît

Fabio Di Bernardini

unread,
Dec 6, 2011, 2:33:17 PM12/6/11
to couch...@googlegroups.com
Hi Benoit,

I'm able to get changes using the blocking wait:

but not using non blocking (gevent or eventlet):

gevent.version_info: (0, 13, 6)
eventlet.version_info: (0, 9, 16)


Where am I doing wrong? Thanks.


Benoit Chesneau

unread,
Dec 6, 2011, 2:52:17 PM12/6/11
to couch...@googlegroups.com

There is an issue in your code. Here is the fixed one:

http://www.friendpaste.com/1RVvKLPLNlVql9oyW06qZ0

hope it helps.

- benoît

Fabio Di Bernardini

unread,
Dec 6, 2011, 4:43:48 PM12/6/11
to couch...@googlegroups.com
Thanks a lot Benoit,

I've never used gevents so far.
Please can you put the example in the official documentation at http://couchdbkit.org/docs/changes_consumer.html?

Bye.
Reply all
Reply to author
Forward
0 new messages