jkbrzt / chat Goto Github PK
View Code? Open in Web Editor NEWA simple chat app created to experiment with Redis, Gevent, Flask & Server-Sent Events.
Home Page: https://twitter.com/jakubroztocil
A simple chat app created to experiment with Redis, Gevent, Flask & Server-Sent Events.
Home Page: https://twitter.com/jakubroztocil
I am running in localhost without using gunicorn
It seems that the redis connection keeped when the page is closed. How to handle client closed event ?
I'm using this model in a simple web application using a naive in-memory publish subscribe model I wrote. It's been incredibly useful, however, I've noticed (and I think I saw the same behavior when using redis) that this loop continues to run well after the client has disconnected. Have you experience and/or resolved that issue?
I'm thinking if I can get a handle to the client's socket I should be able to do a non-blocking test to see if it's still connected and break.
Edit: I was incorrect. Closing issue.
The byte string should be decoded to utf-8, on a side note, the README should mention that the redis server needs to be started before the app is run.
@jakubroztocil would you please provide some explanation regarding running this app through gunicorn + gevent workers?
In particular I can not understand how we're able to perform non-pending request to /stream
with EventSource('/stream')
? (In case of running app with gevent.pywsgi.WSGIServer
I'll receive pending
request for /stream
but with gunicorn+gevent worker - 200 OK
)
When opening a browser, I found there was a line showing "1", which should not be there.
And in event_stream()
function the print shows the following first data:
{'pattern': None, 'type': 'subscribe', 'channel': 'chat', 'data': 1L}
I'm new to this, and wandering what the 1L data is for. From my point of view, it should be empty.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.