I have a problem: I am writing a program in Python 3.2 that requires that a loop run uninterrupted and separate from the rest of the program, but at the same time it must be able to send and receive data (such as a string) from the main part of the script. The parts would work like this:
# Continuing loop (LOOP)
while True:
data.read()
if data[2] == "ff":
string += data
if request = True:
SEND(string, MAIN)
string = []
# Main program (MAIN)
hexValues = REQUEST(string, LOOP)
So, like having two processes of Python running at the same time but talking to each other.
Is this even possible? If so, how should I do it?
EDIT: I am using Ubuntu GNU/Linux and Python 3.2.
This is what the threading module is for. You can also look at multiprocessing.