I'm currently planning a web-app that requires listening permanently to a open socket-connection and writing specifig things to a database.
To get known to flask (framework of my choice) and python in general I want to play around with twitter-streaming-api.
The essential problem is the same. How to implement a permanent "Connection-Listener" for both kind of connection?
Is the below suggested way the best way of doing it?
tweepy Streaming API integration with Django
I somehow don't like the idea of having to implement a system-deamon on the machine.
Edit: Of course I want to serve things to users via HTTP. All this should be non-blocking.
If you want the system to be non-blocking then neither Flask or Django are going to natively provide the support you are looking for. You should probably check out Twisted since its the most mature python project for non-blocking IO: http://twistedmatrix.com/trac/
It provides a solid set of API's for socket-based servers. If you need to integrate with an "regular" webapp, your best bet would be Django since I don't believe anyone has done a Twisted-Flask integration (I could be wrong, just haven't seen it). Here's a link explaining how to setup Django and Twisted in the same environment: http://dreid.org/2009/03/twisted-django-it-wont-burn-down-your.html/
Note: no system daemon required ;)
I recommend Eventlet for event based actions with open-socket.
The other options in python for handling twitter real-time api are twisted and tornado.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With