Friday, September 1, 2017

Re: Channels - Forward messages from a third party async source.

Hey,

You can send onto Channels from anywhere, event loop or no, but if you want a background process that monitors an external source and forwards events from it you will need to write that yourself (I usually suggest management commands for this purpose).

I'm working on hopefully making it easier to write worker processes like this, but that's not something that's ready in the short term.

Andrew

On Fri, Sep 1, 2017 at 3:56 AM, Roger Gammans <rgammans@gammascience.co.uk> wrote:
Hi all,

I'm trying to build a system with a Django frontend which displays live
information from other services on the backend (eg, the one running
python - not the browser) host.

To keep my dependencies as light as possibly I'm trying to avoid import
the settings file for django and channel into the backend services. And
run those a much lighter an simple process which concentrate on their
tasks.

I can easily create an async event in the backend processes; but to
get the channels layer to respond to it; It seems that I need to create
my own thread with it own tight loop doing something like:-

        def forward_sensor_to_web(sensor_gen,dj_channel):
                for sensor_data in sensor_gen():
                        Channel(dj_channel).send(sensor_data.as_json())


Obviously this needs to be kept running and restarted if the
loop/thread raises an exception etc.

Is there any extant best practice for how to set this sort of
architecture up using channels? Can I integrate the into the channels
main Aio loop?  Or is channels to the best way to go?

I'm seeking to make sure I'm not missing anything; before thing start
to get hard to change.

Anybody got any thoughts?

--
Roger Gammans <rgammans@gammascience.co.uk>

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/1504263403.30060.7.camel%40gammascience.co.uk.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAFwN1upd8HhPu2hznKrHsNV_-M5pvAOCJrDKhumEcBpYP_Zncw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment