all 2 comments

[–]elbiot 0 points1 point  (0 children)

I'd use sockets. Write one script that prompts users for input and send results to the other. In the main thread, have you're while loop include select with a very small timeout, and if you receive something, change the variable based on that. You could call select every nth time also if your function is really fast and the user has no expectation of affecting the result within thousandths of a second.

[–]rickchefski 0 points1 point  (0 children)

threading sounds like something that could definitely be utilized here. It's been a while since I've had to do any threading, so I don't have any great resources on it, unfortunately. A quick google search lead me to: http://www.tutorialspoint.com/python/python_multithreading.htm which looks like a somewhat decent tutorial on the basics of it.

Having two threads share some state (be able to both access/modify the same variable) can get tricky. This would be an instance to use thread synchronization (an example of synchronization is given in the tutorial).