stop backgroundworker

20 views
Skip to first unread message

Tommy

unread,
Mar 6, 2017, 11:58:44 AM3/6/17
to Django users
Hi,

I'm new to Django and would need some advice.

I've got a process launched with a command: python manage.py myprocess. I've got an infinite loop there where i use Group("mygroup").send({'text': state_text}). Everything is well displayed on my html page.

However i'd like to use buttons on my html page to stop this loop. Is there a way for my backgroundworker to get the value of which button was press on the html page?

Thank you

Shawn Milochik

unread,
Mar 6, 2017, 12:12:00 PM3/6/17
to django...@googlegroups.com
You'll have to send something from the browser (submit a form, AXAX, or websockets) to a Django view and update something somewhere -- in Redis or your database, probably. Then have your infinite loop check that location for an updated value. I recommend Redis for this purpose.

Melvyn Sopacua

unread,
Mar 6, 2017, 12:51:41 PM3/6/17
to django...@googlegroups.com

+1. In fact, I would not use Django to set the "stop looping" flag, since there is no advantage to that, unless the stops need to be tied to content in the database. But to just alter a value in redis, I'd use Nginx Redis2 module.

--

Melvyn Sopacua

Reply all
Reply to author
Forward
0 new messages