hagsteel / swampdragon-py-client

A python client for swamp dragon
7 stars 1 forks source link

Subscribing to multiple channels leads to failure #2

Open Wing0 opened 9 years ago

Wing0 commented 9 years ago

I'm trying to write a python client that connects to multiple routes simultaneously listening changes in two Django models. However, when subscribing to the second channel, an error appears ERROR:root:pop index out of range and updates from the server are not received anymore. Everything works fine when subscribing only one route at a time.

Here's my code stripped to minimal case:

class NetLink(object):

    def __init__(self, ws_address):
        self.client = DragonClient(
            ws_address, on_channel_message=self.on_channel_message)
        self.client.connect()
        self.client.call_router(
            'subscribe',
            'sample-update',
            callback=self.on_subscribed,
            channel='task-channel1')
        self.client.call_router(
            'subscribe',
            'spread-update',
            callback=self.on_subscribed,
            channel='task-channel2')
Wing0 commented 9 years ago

In addition, there's an error: No handlers could be found for logger "root". However I got rid of the error when added the following code:

import logging
logging.basicConfig()

Again, this error does not come up if subscribing to a single route.

hagsteel commented 9 years ago

I'm working on converting this project into an installable package with tests, I'll fix this in my next push. In the meantime, if you do come up with a solution or some improvements feel free to create a PR

Wing0 commented 9 years ago

Sounds good! Looking forward to the release. In the meanwhile, I already fixed the issue. More details in the pull request.

This was my first public contribution & pull request, so please let me know, if I should have done something differently :)