I'm trying to experiment with using both the threading and Multiprocessing module
import multiprocessing as mp
import threading
from threading import Thread
import time
QP = mp.Queue()
Lock = mp.Lock()
Input = 100
Checked = mp.Value("i",0)
class MultiThreading(threading.Thread):
def __init__(self,QP,Checked):
threading.Thread.__init__(self)
self.QP = QP
self.Checked = Checked
def run(self):
global Input
global Lock
QueueMode = self.QP.get()
First,Second = QueueMode
Lock.acquire()
print ("{} {} - Has Successfully Done".format(First,Second))
Checked.value += 1
time.sleep(0.25)
Lock.release()
if not Input == Checked.value:
t = MultiThreading(QP,Checked)
t.setDaemon(False)
t.start()
def MultiCall(QP,Checked):
for i in range(10):
t = MultiThreading(QP,Checked)
t.setDaemon(False)
t.start()
if __name__ == "__main__":
for i in range(100):
QP.put((i,i+i))
Processes = []
for i in range(4):
p = mp.Process(target=MultiCall, args=(QP,Checked))
Processes.append(p)
p.start()
p.join
while not Input == Checked:
continue
print ("Task Done")
The code above is what i've been currently working on, when i run the code regularly it gets an error either "unable to start new thread" or it just freezes, however when i use the debugger https://www.onlinegdb.com/online_python_interpreter it works but it is slow, so i'm confused as to what is going on.