- python worker for data analysis
- reads responses from a user and returns a new question
- calculates results
RPCClient
an easy way to get access to data without creating a bottleneck or a race conditionworker.py
the main startup script that coordinates responses and calls from the json api to the db.
RPCClient can be called in a similar fashion just like the JSON api, this works asynchronously so there is no hassles with promises or callbacks
choice = client.call(json.dumps({
'method': 'findChoice',
'arguments': [1]
}))
Most of the code is in worker.py
there is a simple if
statement that handles whether or not the script is looking for the next question, or calculating the results.
the key difference between calculating results and searching for the next question is this: When you ask for the next question, the worker calculates the next question, then tells the db worker to read it and pass it to the api when you ask for the results, the worker calculates the results and the worker passes them to the api
I am not a python expert, any refactoring on this would be much appreciated.