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

How to handle client closed event? #2

Open
yishh opened this issue Mar 13, 2013 · 3 comments
Open

How to handle client closed event? #2

yishh opened this issue Mar 13, 2013 · 3 comments

Comments

@yishh
Copy link

yishh commented Mar 13, 2013

It seems that the redis connection keeped when the page is closed. How to handle client closed event ?

@barroca
Copy link

barroca commented Mar 14, 2013

Hey Yishh, did you find a solution for the issue? I'm having the same problem!

@masklinn
Copy link
Contributor

masklinn commented Jun 9, 2013

This should be possible using a closeable iterator: lift the generator in the __iter__ method of an object (can just convert event_stream to a class) and add a close method, which will be called on connection close.

However, this may only happen when a write to the socket fails, so there probably needs to be a "heartbeat" regularly sending something irrelevant (e.g. a line of comment) in order to trigger the failure, and thus the closing of the iterator.

As far as I can see, for the current redis-based implementation this would require a timeout on pubsub.listen(), which I don't believe exists.

Here's a zmq conversion demonstrating it: https://github.com/masklinn/chat/blob/zmq/app.py

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

No branches or pull requests

5 participants
@masklinn @barroca @yishh and others