I am having trouble finding an answer to this question.
I am looking for a framework where I can send a python function to a rest endpoint, and it sends a response upon completion.
If there is no precanned solution, what would be a good set of packages to use to do this?
Maybe you could try to use SocketIO with Celery.
SocketIO is an option to create a channel between clients (web, mobile apps, etc) and server.
When received a specific message (you can create you own protocol) you can call a task in a Message Queue using Celery framework with Redis or RabbitMQ.
Maybe you need to use an another framework called Kombu to be able to send a message using the connection in socketio.
You can find some tips on this link: http://python-socketio.readthedocs.io/en/latest/
I hope I could helped.
Related
I am trying to connect to slack RTM (Real Time Messaging) api and update the database with the messages coming from the slack channel. How should I do that.
Should I run a web-socket client in the background? If so, how to integrate the web-socket client with the Django application.
Is Celery something that I should look into? I was looking into this for the past few hours. Went through a lot of questions. I am not able to figure out the right approach to do that.
You would need a TCP socket.
You will figure out more here: https://realpython.com/python-sockets/
currently, I have a little script that receives a lot of information through various channels using ZeroMQ PUB-SUB sockets.
What i want to do is: receive the info with zmq, process it, and then, send it away through a WebSocket, in order to be able to use it in an AngularJS application, displaying real time information.
All the websocket libraries i have found for python work in an asynchronous way, where i can send messages as a responde to a message the browser send in advance. I don't want to send messages as a response, i want to stream all the information I am receiving, for any instance of my AngularJS app that might be running.
Thanks in advance.
EDIT: I forgot something. I found this How do I stream data through a flask application?, and got it working with flask, but it seems to only work with the flask app from which the websocket is created, i can't connect to it from angular.
One good example is on Miguel Grinberg blog here. He creates a flask backend and uses Angular on front-end.
After the browser open the channel, the back end can send messages any time, without any constraints related to timing.
I'm searching for a way to send push notifications to devices from my django project. I want to send push notifications using pure python, with out third packages like django-gcm or python-gcm.
It is just an HTTP request to an endpoint. The docs explain how to use it. https://developers.google.com/cloud-messaging/downstream
I have a web application running Django and a separate websocket server. Both using single Django model. When Django make changes to the model, I want Django to notify websocket server about this changes.
Obviously, the way of simply connecting to websocket server and sending one message is looking bad due to increasing server load through connecting/disconnecting clients for each user form submit and due to websocket concept in general.
I've heard about solutions using AMQP server for similar purposes. The question is: is that a good idea, or there are better solutions in my case?
Have a look at https://github.com/jrief/django-websocket-redis
Documentation: http://django-websocket-redis.readthedocs.org/en/latest/
I use https://github.com/mrjoes/sockjs-tornado for a Django app. I can send messages from javascript console very easy. But I want to create a signal in Django and send json string once the signal is active.
Could anyone give me a way to send a certain message in Python to sockjs-tornado socket server?
There are few options how to handle it:
Create simple REST API in your Tornado server and post your updates from Django using this API;
Use Redis. Tornado can subscribe to the update key and Django can publish updates to this key when something happens;
Use ZeroMQ (AMQP, etc) to send updates from the Django to the Tornado backend (variation of the 1 and 2).
In most of the cases, it is either first or second option. Some people prefer using 3rd option though.
I've wrote djazator, simple and easy to use django plugin. It uses zeromq for delivering messages from django to sockjs-tornado. Additionally, it can send messages to subset of authenticated django users.
I just put this up https://github.com/amagee/sockjs-client for talking directly to a SockJS server from Python (using xhr streaming).