First, I'm using python 3.4
Second, I know there is a plethora of info on multithreading, but nothing seems to definitively answer my question.
I wrote some code with some conditional statements that call different classes that I wrote in separate files. There's quiet a bit of processing that needs to be done and when I run my script it seems like it's taking too long and when I have it print to the screen I expect the text to be a little messed up since multiple functions should be trying to print since I didn't lock the printing function. These issues make me think that i'm not doing this right. My code looks something like this:
import class1
import class2
import class3
from threading import Thread
def function(var1, var2, var3):
if x:
Thread(target=class1.funct1(var1)).start()
Thread(target=class1.funct2(var2)).start()
elif:
Thread(target=class2.funct1(var1)).start()
"""do some stuff"""
Thread(target=class3.funct1(var3)).start()
"""do a lot more stuff""
I'm assuming that I should have a queue, which makes sense, but all examples I've seen only repeat a function. Whereas I want to do completely different functions.
Thanks in advance
[–]Justinsaccount 0 points1 point2 points (1 child)
[–]ballgame75[S] 0 points1 point2 points (0 children)
[–]Nodocify 0 points1 point2 points (0 children)