Feb-21-2019, 12:34 PM
Hi
I'm having a big trouble to get this to work.
I have a function that I want to put in a thread (or multiprocess). This function requires 3 variables.
One of the variables (var_1) is static and no problem passing it through args in the thread module.
The second variable (var_2) changes during the main program
The last variable (flag) i want to use as a trigger when it gets True in the main program.
The "mental" structure of the program should be:
main.py
Someone guru could help me?
I'm having a big trouble to get this to work.
I have a function that I want to put in a thread (or multiprocess). This function requires 3 variables.
One of the variables (var_1) is static and no problem passing it through args in the thread module.
The second variable (var_2) changes during the main program
The last variable (flag) i want to use as a trigger when it gets True in the main program.
The "mental" structure of the program should be:
main.py
import threading from test import function import time global flag, var_2 var_1 = "var_1" t = threading.Thread(target=function, args=(var_1,)) t.start() while True: var_2 = "var_2 (that changes in each while loop" flag = True time.sleep(1) flag = Falsetest.py
def function(var_1): global var_2, flag while True: if flag == True: print(var_1 + var_2)But this does not work i think
Someone guru could help me?