Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

when my redis is crash.pub,sub will not reactivate #143

Closed
larryclean opened this issue Nov 6, 2017 · 3 comments
Closed

when my redis is crash.pub,sub will not reactivate #143

larryclean opened this issue Nov 6, 2017 · 3 comments
Assignees
Labels

Comments

@larryclean
Copy link

Hi @miguelgrinberg !
when my redis is crash.pub,sub will not reactivate.
i try repair in asyncio_redis_manage.py.
The following code:

    async def _publish(self, data):

        if self.pub is None:
            self.pub = await aioredis.create_redis((self.host, self.port),
                                                   db=self.db,
                                                   password=self.password)
        try:
            await self.pub.ping()
        except:
            self.pub = await aioredis.create_redis((self.host, self.port),
                                                   db=self.db,
                                                   password=self.password)
        return await self.pub.publish(self.channel, pickle.dumps(data))

    async def _listen(self):
        if self.sub is None:
            self.sub = await aioredis.create_redis((self.host, self.port),
                                                   db=self.db,
                                                   password=self.password)
            self.ch = (await self.sub.subscribe(self.channel))[0]

        while True:
            try:
                return await self.ch.get()
            except:
                value=True
                while value:
                    try:
                        self.sub = await aioredis.create_redis((self.host, self.port),
                                                               db=self.db,
                                                               password=self.password)
                        value=False
                    except:
                        pass
                self.ch = (await self.sub.subscribe(self.channel))[0]
                return await self.ch.get()
@miguelgrinberg
Copy link
Owner

I'll look into this. The generic except clauses need to be made more specific, but I think I understand what problem is anyway.

@miguelgrinberg miguelgrinberg self-assigned this Nov 6, 2017
@larryclean
Copy link
Author

When my redis server is suspended, restart success will not receive pub information again.

@miguelgrinberg
Copy link
Owner

@Larry-Dev can I ask you to test the master branch of this package and let me know if your problems with reconnecting to redis are addressed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants