item.add_button(item.view_form.find(".form-footer"), 'Load CPU').click(function() {
item.server('bck');
});
Paste above code into form Server Module. Do the pip part. Click the button
load_all_cores will not run due to:
Tested with v112 and v6...
Of course, this will not solve the issue with running jobs, even if the button works. It is just the matter of time when someone will need this imo.
Good reading:
So here is the thing, the above article is easy, but when I try to integrate with Jam, here is what happens in rq queue when "redis" is mapped to button:
from redis import Redis
import rq
def redis(item):
print('Redis started)')
queue = rq.Queue('microblog-tasks', connection=Redis.from_url('redis://127.0.0.1:6379'))
job = queue.enqueue(example, 23)
def example(seconds):
print('Starting task')
for i in range(seconds):
print(i)
time.sleep(1)
print('Task completed')
.
.
raise ValueError('Invalid attribute name: %s' % name)
ValueError: Invalid attribute name: als.journals.email_aliases.example
So rq fails because I have no idea how to map "example" to a valid queue. Why is rq getting als.journals.email_aliases.example?
To demonstrate how nicely the above works from the article (I just created tasks.py in a folder):
>>> from redis import Redis
>>> import rq
>>> queue = rq.Queue('microblog-tasks', connection=Redis.from_url('redis://127.0.0.1:6379'))
>>> job = queue.enqueue('tasks.example', 23)
>>> job.is_finished
False
>>> job.meta
{}
>>> job.get_id()
'43b45dad-5d3c-4ffc-a236-3222fec1ed03'
>>> job.refresh()
>>> job.meta
{'progress': 56.52173913043478}
>>> job.refresh()
>>> job.meta
{'progress': 73.91304347826087}
>>> job.refresh()
>>> job.meta
{'progress': 95.65217391304348}
>>> job.is_finished
True
And here is the result from the queue:
.
.
.
16:05:30 microblog-tasks: tasks.example(23) (43b45dad-5d3c-4ffc-a236-3222fec1ed03)
Starting task
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Task completed
16:05:53 microblog-tasks: Job OK (43b45dad-5d3c-4ffc-a236-3222fec1ed03)
16:05:53 Result is kept for 500 seconds
.
.
Absolutely no idea how to do it with Jam....
Thanks