Scheduler: Is it possible to assign a task to all workers that are part of a group?

68 views
Skip to first unread message

Francisco Ribeiro

unread,
May 4, 2018, 6:36:30 PM5/4/18
to web2py-users
The question refers to submitting a task simultaneously to all workers within a group.

Thank you

Massimo Di Pierro

unread,
May 5, 2018, 11:16:53 PM5/5/18
to web2py-users
No. I do not believe there is any way to guarantee that every work will execute the same task.

Francisco Ribeiro

unread,
May 6, 2018, 11:16:08 AM5/6/18
to web...@googlegroups.com
Thank you for confirming.

I presume that I still can take a list of workers belonging to a single group and assign the same task multiple times (once per worker), which would still suit my needs (expect if i want to cancel it for whatever reason which becomes harder / less convenient). Do you see any problem doing that?

Francisco Ribeiro

unread,
May 7, 2018, 2:13:02 PM5/7/18
to web2py-users
I have been testing my own hypothesis, it didn't work. I was unable to assign a task to a specific worker, I can only assign tasks to groups. Please correct me if I am wrong...

Niphlod

unread,
May 8, 2018, 2:52:29 PM5/8/18
to web2py-users
hint: if the api doesn't allow it, it's not an envisioned scenario.

That being said, there's no limit on the worker-group configuration. 
As auth relies on RBAC, workers rely on groups. 
A particular group is able to process a given task ? Queue the task assigning the correct group.
Only one worker is able to process tasks of a specific group ? voilà!
It's perfectly fine to run 10 workers and have 10 groups, even if each group holds just one worker...

Francisco Ribeiro

unread,
May 8, 2018, 11:16:23 PM5/8/18
to web...@googlegroups.com
Thank you, that has crossed my mind but I would then have to create another abstraction on top of the Scheduler groups to represent, well... groups. I even thought of conventions like common prefixes to identify which "user-group" belongs to which "group-group". Anyway, I gave up on the idea and is it looked to cluttered and implemented this functionality on the Scheduler, will submit a PR in case you are interested.

Basically, all you do is to create a task with broadcast=True and it should hit all the workers within the assigned worker_group. This should work even if new workers join the group later on and for both one-off tasks or those with an unlimited number of _repeats_. Finally, if you stop / disable / delete the broadcast task, no more tasks should be triggered like it, so you stop broadcasting. Happy to document this better, if are you happy to include it.

Kind regards,
Francisco
Reply all
Reply to author
Forward
0 new messages