Fix the scriptrunner to use consumer-producer model for scheduling scripts

Bug #1000386 reported by Jono Bacon
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Ubuntu Accomplishments Daemon
Fix Released
Medium
Rafał Cieślak

Bug Description

As per the Twisted team's recommendations, we should use threads to manage the script runner.

Revision history for this message
Rafał Cieślak (rafalcieslak256) wrote :

Begin more exact: we want to use is a consumer-producer model. API calls like "run_script(accomID)" should add the acomID the the queue, while some separate thread would sleep until there are some new data in the queue, and process them by running related scripts.

Revision history for this message
Rafał Cieślak (rafalcieslak256) wrote :

I have managed it to get it to work using threads.
I run threads.deferToThread(scriptrunner_function) in the API __init__. I also create a threading.Condition(), and then use wait()/notify() to tell the scriptrunner_function that there are new scripts scheduled on the queue.

However, although it seems to work, I feel this is not the right approach. Twistd is all about getting rid of separate threads, and thus asynchronous code is recommended.

summary: - Fix the scriptrunner to use threads
+ Fix the scriptrunner to use consumer-producer model for scheduling
+ scripts
Changed in ubuntu-accomplishments-daemon:
milestone: 0.2 → 0.3
Jono Bacon (jonobacon)
Changed in ubuntu-accomplishments-daemon:
assignee: nobody → Rafal Cieślak (rafalcieslak256)
Changed in ubuntu-accomplishments-daemon:
status: Confirmed → Fix Committed
Changed in ubuntu-accomplishments-daemon:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.