1
0
Fork 0
mirror of https://github.com/dbarzin/pandora-box.git synced 2025-07-18 21:09:41 +02:00

add threading

This commit is contained in:
dbarzin 2023-03-04 17:51:50 +01:00
parent f1b9342f98
commit c265840ca2
2 changed files with 755 additions and 642 deletions

File diff suppressed because it is too large Load diff

View file

@ -15,20 +15,19 @@ class myThread (threading.Thread):
def run(self): def run(self):
print(f"Thread-{self.id} Starting ") print(f"Thread-{self.id} Starting ")
process_data(self.id, self.q) self.process_data()
print(f"Thread-{self.id} Done.") print(f"Thread-{self.id} Done.")
def process_data(self):
def process_data(id, q): while not exitFlag:
while not exitFlag: queueLock.acquire()
queueLock.acquire() if not workQueue.empty():
if not workQueue.empty(): data = self.q.get()
data = q.get() queueLock.release()
queueLock.release() print(f"Thread-{self.id} processing {data}")
print(f"Thread-{id} processing {data}") else:
else: queueLock.release()
queueLock.release() time.sleep(1)
time.sleep(1)
maxThread = 2 maxThread = 2