How can I access the results of a Celery task in my main Django application process? Or, how can I publish an existing socket connection from a separate process?
I have an application in which users get points. When an assessment is recorded, calculations are made (progress towards goals, etc.), and based on these calculations, notifications are sent to interested users. Calculations can take 30 s +, so to avoid a sluggish UI, these operations are performed in the background using the Celery task triggered by the post_save signal of my Score model.
Ideally, the post_save signal on my Nofication model will post a message to subscribers (I use django-socketio, a wrapper for gevent-socketio). It seems simple ...
- Create rating
- Do some calculations in a new instance of Score in the background process.
- Based on these calculations, create a notification
- In Notification Save mode, grab an instance and publish to signed clients through a socket connection.
However, after trying the following, I'm not sure if this is possible:
passing the gevent SocketIOServer instance to the callback method called by the job, but this requires etching the transferred object, which is impossible
storing the session_id socket (other than Django session_id) in memchache and retrieving this during the Selery task.
Redis pubsub, , post_save , , Redis, ( ) .
Redis, . , gevent.greenlets.Greenlet gevent .
, . ?