Client redis connection using brukva client

45 views
Skip to first unread message

Burak DEDE

unread,
Dec 12, 2011, 7:50:25 PM12/12/11
to redi...@googlegroups.com
I am building Tornado application and using redis pub/sub with brukva async client provided here. ( https://github.com/evilkost/brukva )

During the long polling operation I am using the below code and say when two client start to talk and post message each other I checked the redis server activity and total number of clients connected is increasing on top of each other. So is this default behaviour or what kind of connection strategy should I use seems like this connection creation in every post update is wrong ?

class MessageUpdatesHandler(BaseHandler):
@tornado.web.authenticated
@tornado.web.asynchronous
def post(self):
    self.listing_id = self.get_argument("listing_id", None)
    self.cursor = self.get_argument("cursor", None)
    self.client = brukva.Client()
    self.client.connect()
    self.client.subscribe(self.listing_id)
    self.client.listen(self.on_new_messages)

def on_new_messages(self, messages):
    # Closed client connection
    if self.request.connection.stream.closed():
        return
    msg = json.loads(messages.body,'ascii')
    self.finish(dict(messages=[msg]))
    self.client.unsubscribe(self.listing_id)

def on_connection_close(self):
    # unsubscribe user from channel
    self.client.unsubscribe(self.listing_id)
    self.client.disconnect()

--
Burak DEDE
www.burakdede.com
www.twitter.com/burakdede

Konstantin Merenkov

unread,
Dec 13, 2011, 3:16:03 AM12/13/11
to Redis DB
Hello

On 13 дек, 04:50, Burak DEDE <burakded...@gmail.com> wrote:
> I am building Tornado application and using redis pub/sub with brukva async
> client provided here. (https://github.com/evilkost/brukva)
>
> During the long polling operation I am using the below code and say when
> two client start to talk and post message each other I checked the redis
> server activity and total number of clients connected is increasing on top
> of each other. So is this default behaviour or what kind of connection
> strategy should I use seems like this connection creation in every post
> update is wrong ?

Maybe brukva doesn't close the socket properly? Just a guess.

Burak DEDE

unread,
Dec 13, 2011, 4:56:51 AM12/13/11
to redi...@googlegroups.com
Yeah it could be, here is a issue I opened https://github.com/evilkost/brukva/issues/20 
And I still couldnt find a propery way to initiate connection by the way. If anyone used brukva (or redis doesnt matter) before could show how handle connection ? 

--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
To post to this group, send email to redi...@googlegroups.com.
To unsubscribe from this group, send email to redis-db+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/redis-db?hl=en.

Reply all
Reply to author
Forward
0 new messages